(Almost) all of my solutions to the 2023 edition of Advent of Code.
Advent of Code is a series of Christmas-themed programming challenges from Dec. 1st-25th:
- At midnight (Eastern), one problem description (in narrative prose), sample input/answer, and input file are posted.
- Input files are personalized/randomized for each contestant.
- The contestant submits the answer (usually a 64-bit or less integer) for the given problem and input.
- When the contestant submits the correct answer, the second challenge's problem description is unlocked.
- The second challenge usually uses the same input file as the first, but the problem requires interpreting it in a more computationally intensive way.
- The contestant submits the answer (same format) for the second problem.
My solutions are organized by day, with independent Python files for part 1 and part 2.
In Advent of Code, the contestant only needs to come up with a solution for a single specific, known input, and they do not need to "show their work".
Contrast with LeetCode, etc. where the candidate must provide a self-contained piece of code with limited dependencies that produces the right answers for a test suite of opaque inputs spanning the problem space.
Advent of Code inputs are also sometimes structured to yield an answer more readily than the general formulation presented in the problem.
As such, it lends itself to tool-assisted (semi-automated) solves.
Specific examples:
- Day 8 Part 2 (solution lost in a Git mishap): My solution here relied on several simplifying aspects of the input data (overall structure, plus position of Z being equal to loop length) to obtain the answer with a plain least common multiple.
- I think some variation on the Chinese Remainder Theorem would handle cases where the lead-ins and Z positions were less carefully coordinated.
- Day 21 Part 2: This was an involved Python -> Google Sheets -> Python process (detailed here).
- The formula derived by polynomial regression could also be found by summing contributions from core (completely reachable) and edge (partially reachable) grid tiles - no Google Sheets required.
- Thoughts about a potential fully-generalizable solution are in my writeup.
- Day 24 Part 2: I used sympy to solve a system of equations for a few hailstones.
- There's presumably an algebraic approach to combining the hailstones' paths without using this library.
- Day 25 part 1: I found the three edges to cut by graphing it in graphviz and manual inspection.
- A fully automatic algorithmic approach would probably resemble max-flow/min-cut.