After my recent adventures learning Rust, I
decided to follow Advent of Code 2024 in
Rust.
It was my first AoC and I came for the puzzles and learning, not for the
leaderboard. I’ll chip away at the puzzles at my leisure, in the occasional
evening here or a weekend there. This article covers days 1 through 5.
I’ll publish later articles as I solve more puzzles (or never, if I
decide to pursue an actual project instead or life happens).
My goal here is to share a bit about the challenges I encountered and
any insights (or lack thereof) I had on the puzzles and on doing them
in Rust. I don’t plan to publish the full source code, so I won’t spoil
the fun of figuring things out yourself, but I maybe having some notes
on problems I encountered helps someone if they are stuck.
Before we dive in, let me compliment Eric and the AoC team on AoC.
It’s clear that a lot of thought has gone into the puzzles, but I
also dig the charming story and the fantastic “ASCII with sparkles”
presentation.
This is the third article in a series covering Advent of Code 2024 in Rust.
Day 16: Reindeer Maze This puzzle asks to search for paths in a maze with different costs for going straight (1) vs. taking a 90-degree turn (1000). I thought this looked really simple, completely missing the challenge at first. I figured I could just run Dijkstra’s algorithm, which I already had implemented for day 10’s Hoof It puzzle.
This is the third article in a series covering Advent of Code 2024 in Rust.
Day 11: Plutonian Pebbles This puzzle presents some magic “pebbles” with rules governing how they multiply, asking to compute the total number of stones after applying the rules a certain number of times.
Of course a first idea here is the brute force approach where we recursively apply the rules to the input and count the number of stones in the end.
This is the second article in a series covering Advent of Code 2024 in Rust.
Day 6: Guard Gallivant This puzzle asks to trace the path taken by a “guard” in a simple grid with obstacles. In the first part of the puzzle, the guard simply turns right at every obstacle and the goal is count the number of fields covered until they exit the grid.
I built some basic data structures to represent the grid with marked fields, the guard with a position and direction, and I then implemented the prescribed logic, marking fields as the guard moves.
Day 1: Historian Hysteria The first puzzle aks to compute a few things on two lists of numbers, including their pairwise distance and multiplying numbers by their frequency in the second list.
Not much to see here, the main effort went into creating some basic outline of Rust crate with per-day modules and parsing the input. The actual solutions were mainly done with sorting/mapping and creating a frequency map for the second part.