These are my solutions to Advent of Code 2023.
They are all coded in Java, needing Java 21 and --enable-preview
(for string templates).
- Day 1: solution (extracting integers from strings).
- Day 2: solution (possible draws from a bag of coloured cubes).
- Day 3: solution (extracting integers from a grid with adjacent characters).
- Day 4: solution (evaluating scratch cards).
- Day 5: solution (tracing number ranges through a sequence of maps).
- Day 6: solution (timing races).
- Day 7: solution (evaluating poker hands).
- Day 8: solution (sequences of left-right choices through a graph).
- Day 9: solution (successive differences).
- Day 10: solution (length and enclosed area of a path).
- Day 11: solution (cosmic expansion).
- Day 12: solution (matching wildcards against counts).
- Day 13: solution (searching for reflections).
- Day 14: solution (cycles of rolling rocks).
- Day 15: solution (hashing).
- Day 16: solution (tracing a beam with splitting).
- Day 17: solution (least-cost path with constraints).
- Day 18: solution (area enclosed by a path).
- Day 19: solution (DFA with conditions on 4 variables).
- Day 20: solution (cycling behaviour of circuits).
- Day 21: solution (counting paths in a graph).
- Day 22: solution (3D bricks falling vertically).
- Day 23: solution (longest path through a graph).
- Day 24: solution (intersections of 3D lines).
- Day 25: solution (finding a 3-cut in a large graph).
All solutions are entirely the work of Éamonn McManus except as noted below.
-
Day 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.
-
Day 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.
-
Day 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.
-
Day 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.