Articles tagged #advent-of-code
Part 1
In the day 2 challenge, we're playing Rock Papers Scissors.
We're given a strategy guide like so:
A Y B X C Z
Left column is "their move": A means Rock, B means Paper, C means Scissors. Right column is "our move": X means Rock, Y means Paper, Z means Scissors.
Each line corresponds to a turn, and we must calculate the total score we get. Picking "Rock" gives 1 point, "Paper" gives 2 points, and "Scissors" gives 3. Losing the round gives 0 points, drawing gives 3, winning it gives 6.
Two years ago, I did part of Advent of Code 2020 using the Rust language. It was a lot of fun, so let's try it again!
The problem statement
Our input looks something like this:
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Each group of lines separated by an empty line is a list of food items an elf is carrying: each line corresponds to the number of calories in that food.
Let's use the Advent of Code 2022, a series of programming challenges of increasing difficulty, to learn more about the Rust programming language.
It's time for the Day 14 problem!
After the hassle that was Day 13, I hope this time we'll have a relatively chill time. And, at least for Part 1, that is true.
Our input looks something like this:
mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X mem[8] = 11 mem[7] = 101 mem[8] = 0
mem
is our memory. Our addresses are 36-bit wide, but as you'll see, that
doesn't matter much.
In the Day 13 problem, we're trying to take the bus.
Our input looks like this:
939 7,13,x,x,59,x,31,19
The first line indicates the earliest minute we can leave from the bus terminal, and the second line indicates the "identifier" of the buses that are active.
Each bus departs every "bus ID" minutes - bus 7 leaves at minute 0, minute 7, minute 14, minute 21, etc. The question is: which bus can we take first (apparently they either all go to the same destination, or we don't really care where we're going), and how long do we have to wait for it?
Time for the Day 12 problem!
In this problem, we have a ship. And we have navigation instructions:
- Action
N
means to movenorth
by the given value. - Action
S
means to movesouth
by the given value. - Action
E
means to moveeast
by the given value. - Action
W
means to movewest
by the given value. - Action
L
means to turnleft
the given number of degrees. - Action means to turn the given number of degrees.
Another day, another problem.
This time the problem looks suspiciously like Conway's Game of Life, or, I guess, any old Cellular automaton.
We have a map like so:
L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLLL L.LLLLLL.L L.LLLLL.LL
And for each iteration:
L
symbols turn into#
if there's no#
in any of the 8 adjacent cells
Day, 10! Day, 10!
Okay, Day 10.
Again, the problem statement is very confusing - but what it all boils down to is this. We have a list of numbers:
16 10 15 5 1 11 7 19 6 12 4
To which we need to add 0
and whatever the maximum was, plus three:
16 10 15 5 1 11 7 19 6 12 4 0 22
From there on, if we take them in order, we'll have gaps of 1 and gaps of 3:
Go back to the homepage.