## Source: Day 4: Scratchcards

## Part 1

Simulate scratchcards. Given a list of winning numbers and guessed numbers, count how many guessed numbers are in the winning list. Your score is 1, 2, 4, 8, … for 1, 2, 3, 4, … matching numbers.

Simulate scratchcards. Given a list of winning numbers and guessed numbers, count how many guessed numbers are in the winning list. Your score is 1, 2, 4, 8, … for 1, 2, 3, 4, … matching numbers.

Take as input a 2D grid of numbers or symbols (

`.`

represents empty space). Numbers will be 1 or more digits written horizontally which should be concatenated (`.467*`

is the number`467`

followed by the symbol`*`

).Sum all numbers that are adjacent (including diagonally) to at least one symbol.

Play a game where you have some number of red, green, and blue dice in a cup, which you draw and roll (without replacement). Which game is possible with only 12 red, 13 gree, and 14 blue cubes?

Input will look like: `Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green`

Given a list of alphanumeric strings, find the first and last digit on each line (they may be the same). Concatenate each pair and sum them.

Another year, another Advent of Code.

Like last year, we’re doing Rust. I’ve really grown to love the language since last year… and hopefully I’ve learned a bit more about how to write more ‘proper’ Rust. I know I had some issues last year. Functional… but it could be better.

Let’s see how it goes!

For full solutions, as always, I post to GitHub (including previous years and possibly some I haven’t written up yet): jpverkamp/advent-of-code

It’s been a bit, but I hope it’s worth it. StackLang, part 5: compiling to C!

StackLang, part 4: an interpreter. Here we go again!

This time, the goal is to actually get code running

StackLang, part 3: parsing. This is going to be the most complicated one thus far! Onward.

StackLang, part 2: lexing.

It’s quite often the simplest part of implementing a programming language (although parsers for s-expression based languages come close), but it’s still something that needs done. So here we go!

I enjoy writing programming languages. Example: Tiny. Let’s do that again.

This time, StackLang:

```
{
@[n fact]
1
{ n 1 - $fact fact n * }
N 1 <= if
} @fact
5 $fact fact writeln
```

Bit of gibberish there, I suppose, but the goal is to write everything in a postfix/stack based model. So `n 1 - $fact fact n *`

is equivalent to `fact(fact, n - 1) * n`

in a more traditional language.

Over the next few posts, I hope to write up where I am thus far and what’s next.