These are my solutions to Advent of Code 2023 for years 2022, 2023, 2024 (ongoing). They are all coded in Java, needing Java 21 at least.
To run Day 21 of 2024, say, you must build with a puzzle input in src/advent2024/puzzle21.txt
.
- 2022-12-01: solution (maximum sums of numbers).
- 2022-12-02: solution (rock paper scissors).
- 2022-12-03: solution (finding items common to sets).
- 2022-12-04: solution (overlaps between number ranges).
- 2022-12-05: solution (moving crates between stacks).
- 2022-12-06: solution (first occurrence of n distinct characters in a string).
- 2022-12-07: solution (directory hierarchy sizes from command outputs).
- 2022-12-08: solution (visibility from trees in a forest).
- 2022-12-09: solution (maintaining minimum distances in a rope as it moves).
- 2022-12-10: solution (simulating a CPU drawing pixels on a CRT).
- 2022-12-11: solution (monkeys throwing items based on arithmetic operations).
- 2022-12-12: solution (shortest path climbing).
- 2022-12-13: solution (comparing nested lists).
- 2022-12-14: solution (falling sand forming piles).
- 2022-12-15: solution (beacons and sensors with Manhattan distances).
- 2022-12-16: solution (opening valves and traversing tunnels).
- 2022-12-17: solution (falling rocks and gas jets).
- 2022-12-18: solution (exposed surface area of cubes).
- 2022-12-19: solution (choosing between cost sets for building robots).
- 2022-12-20: solution (moving numbers in a cyclic list).
- 2022-12-21: solution (solving an equation expressed as a tree).
- 2022-12-22: solution (following paths on the surface of a cube).
- 2022-12-23: solution (fixed point of cellular automaton).
- 2022-12-24: solution (path through a grid with shifting obstacles).
- 2022-12-25: solution (base 5 numbers using digits -2..2).
- 2023-12-01: solution (extracting integers from strings).
- 2023-12-02: solution (possible draws from a bag of coloured cubes).
- 2023-12-03: solution (extracting integers from a grid with adjacent characters).
- 2023-12-04: solution (evaluating scratch cards).
- 2023-12-05: solution (tracing number ranges through a sequence of maps).
- 2023-12-06: solution (timing races).
- 2023-12-07: solution (evaluating poker hands).
- 2023-12-08: solution (sequences of left-right choices through a graph).
- 2023-12-09: solution (successive differences).
- 2023-12-10: solution (length and enclosed area of a path).
- 2023-12-11: solution (cosmic expansion).
- 2023-12-12: solution (matching wildcards against counts).
- 2023-12-13: solution (searching for reflections).
- 2023-12-14: solution (cycles of rolling rocks).
- 2023-12-15: solution (hashing).
- 2023-12-16: solution (tracing a beam with splitting).
- 2023-12-17: solution (least-cost path with constraints).
- 2023-12-18: solution (area enclosed by a path).
- 2023-12-19: solution (DFA with conditions on 4 variables).
- 2023-12-20: solution (cycling behaviour of circuits).
- 2023-12-21: solution (counting paths in a graph).
- 2023-12-22: solution (3D bricks falling vertically).
- 2023-12-23: solution (longest path through a graph).
- 2023-12-24: solution (intersections of 3D lines).
- 2023-12-25: solution (finding a 3-cut in a large graph).
- 2024-12-01: solution (pairing up integers from two lists).
- 2024-12-02: solution (checking adjacent deltas in lists of numbers).
- 2024-12-03: solution (extracting instructions from a string including junk).
- 2024-12-04: solution (word-search XMAS).
- 2024-12-05: solution (sorting number lists based on pairwise orders).
- 2024-12-06: solution (paths in a grid with obstacles).
- 2024-12-07: solution (making equations true by inserting operators).
- 2024-12-08: solution (points aligned with pairs of points in a grid).
- 2024-12-09: solution (disk compaction).
- 2024-12-10: solution (counting paths in a graph).
- 2024-12-11: solution (exponential evolution of a list of numbers).
- 2024-12-12: solution (perimeters and side counts of regions in a grid).
- 2024-12-13: solution (simultaneous Diophantine equations).
- 2024-12-14: solution (vector-moving robots forming a Christmas tree).
- 2024-12-15: solution (robot pushing stacks of boxes).
- 2024-12-16: solution (shortest path through a maze with penalty for turns).
- 2024-12-17: solution (quining a program on a 3-bit CPU).
- 2024-12-18: solution (shortest path through grid with obstacles).
- 2024-12-19: solution (counting substring splits).
- 2024-12-20: solution (shortest path through maze with one jump allowed).
- 2024-12-21: solution (navigating multiple levels of keypads).
- 2024-12-22: solution (best sequence of differences in parallel pseudorandom streams).
- 2024-12-23: solution (largest clique in a graph).
- 2024-12-24: solution (fixing an adder circuit by swapping wires).
- 2024-12-25: solution (trivial problem with measuring column heights).
All solutions are entirely the work of Éamonn McManus except as noted below.
-
2022-12-16 (opening valves and traversing tunnels).
My original solution was very inefficient and I was able to make it much faster using an idea from Martijn Pieters (zopatista) on [Reddit] (https://www.reddit.com/r/adventofcode/comments/zo21au/2022_day_16_approaches_and_pitfalls_discussion/).
-
2023-12-17 (least-cost path with constraints on moves)
I gave up before finding the right Dynamic Programming approach. I ended up copying my approach from David Brownman.
-
2023-12-20 (pulse propagation)
I had a strong suspicion of what the right approach might be for Part 2 but would have needed to investigate in detail to confirm. Instead I looked online and found this description by Dazbo, which confirmed my suspicion. Then solving was straightforward.
-
2023-12-21 (counting paths in an infinite graph)
I was not really motivated to put in the work for Part 2 so I outright cheated, by copying this solution by Michiel Graat.
-
2023-12-24 (intersections of 3-dimensional lines)
This curious puzzle was entirely solvable with algebra, the computer only serving to solve simultaneous equations. I did the first part myself, but did not find the right approach for the second part on my own. The excellent explanation and solution by @dirk527 showed me the right path, but then there wasn't much for me to write.
-
2024-12-15 (robot pushing stacks of boxes).
I found this very tricky to get right. In order to track down a bug, I compared the output from my solution with the output from the solution by Balázs Zaicsek (which I picked because it was in Java).