4 minute read

I completed Advent of Code 2025! Yay!

Lessons learned:

  • Every problem has a parse and solve step. Every puzzle has this step where you take the puzzle input and parse it into some internal domain model/logic. Often times these are self-defined python objects. Then, there is always a second step of applying complex logic on these domain objects to figure out the answer. This is problem decomposition! These are two separate steps that can be solved relatively independently.
  • If it works it ain’t stupid. Build the fastest thing you can think of. When you run into a bottleneck, then start optimizing. I often tried to guess part 2 and every time I tried I was wrong.
  • The journey is the reward. The biggest lesson is that the journey is the reward. It’s not about the answer or the final destination. It’s about the struggle for the answer. It’s about thinking and trying things and not getting the right answer and trying again. The journey is the reward.

Technical lessons learned:

  • Grid-as-dict trick. You can represent grids as dictionaries and have them handle the out of bounds logic. Makes life easier.
  • Memoization/Cache. When working on recursion/dp problems use @cache which is shorthand for functools.lru_cache(None). This is very powerful and very fast if your machine can handle it. Avoid repetitive work.
  • Write out the base case on paper. I can think of 2 examples where I might have gotten the answer myself if I had written out the base case on paper for n=1, n=2, etc.
  • Tests are invaluable to save your thinking. I like writing little tests. This takes some upfront effort but it saves me a lot of time debugging. Tests are a bit like headlights, sometimes you need them sometimes you don’t.
  • Split up the problem into subproblems. For example, there was one exercise where we had to calculate the paths through certain nodes. I should have split up each part and calculated them independently and then multiply the subpaths.
  • Wrap around an array with modulo. You can wrap around an array of length n with arr[i] and then arr[(i+1) % n].

Notes per day (raw, unedited):

  • Day 3: Writing out the base case on paper and building up from there what helped me solve it.
  • Day 4: Here I applied the “represent a grid as a dict”-trick, where you represent a grid of points as a dictionay to take care of the out of bounds logic.
  • Day 5 part 2: This was difficult. I had to look up an algorithm for merging closed intervals. It would have been easier if I had written out the algorithm for small n on paper first.
  • Day 6 part 1: Didn’t expect the regex to be so simple
  • The problem is that if you “update” then you need to remember that you hit this specific bad boy otherwise on the next update you update the other one.
  • Looked a bit at hints for day 7 part 2. The idea is to use memoization or some layer of caching, for example with the first exercise. You build up a map and then use that as your cache in the second exercise.
  • Day 7 part 2 I think I got the recursion down, now I just need to cache/memoize… what a trip… the journey is the reward. Fighting with edge cases and recursion etc.
  • Day 8 part 1 I think the trick here is to calculate distances and then to save them somehow so you don’t have to recompute them. Calculating all of them sounds very O(n**2) which doesn’t scale
  • Little tests are invaluable for saving progress and ensuring correctness of your code and finding little bugs like copy pasting the left/right wrong in the tachy beam example!
  • Lekker puzzelen, lekker spelen, leuk. Voelt altijd kerstig.
  • Day 8 part 1 Struggled with this one. Missed one edge case where a node can connect two graphs. Also silly typo using idx instead of count_idx[0]. Investing in debugging tools helps a lot!
  • Getting tired… making silly mistakes like max(sorted) instead of max(sorted([0:3]..))
  • 2025-12-08 23:32:28 YES!! I got it!! Finally…
  • Day 9 part 2 There is a way of doing things efficiently that we are all missing, and I find it fascinating. How do you quickly check if some square is in another square, but fast?! What are we missing?!
  • Day 10 part 1 Is using chatgpt for regex cheating? I don’t know Mistake was NOT removing the cache
  • Day 10 part 2 Cheated a bit here. Did not write the integer linear programming myself. I get the idea and the concept but I let chatgpt help me a bit. Once I wrote out the equations I could put it in the program.
  • Day 11 part 2 took me a while but splitting up the problem into smaller subproblems, instead of all paths take the paths from svr to fft and then to dac and then to out and then the powerful recursion plus memoization.
  • Day 12: Feels very backtracky?
  • Man day 12 is tough! I have to write a lot of boilerplate code to get to the good stuff. Tests really help with confidence here. Building up the larger solution out of smaller submodules such as is_safe_to_place, is_touching, etc Lots of work to do!
  • FUCK! Day 12 is fucking brutal. So long. So much functions to write. So much functions to test. Fingers crossed that I didn’t make a mistake.
  • OK so now I wrote all the big functions and now I have to piece them together in the recursive backtracking algorithm. Fingers crossed whether this works. FUCK!

https://app.bannerbear.com/projects/POobgvMNDkxzxAYW70/templates/3g8zka5Y2OlaDEJXBY

https://www.photopea.com/

Subscribe

Comments