Advent of Code 2025

I completed Advent of Code again this year, using Kotlin once more. I’d failed to read the full details on the first day and had to have it pointed out to me that there would only be 12 days this year. There was a massive sigh of relief, not least from the rest of my family!

The first eight days all went very smoothly. I was able to get both parts completed in half an hour or less before starting work in the morning. There was even time to tidy up the code a bit so I could push it to GitHub on the same day.

Everything fell apart a bit for Part 2 on Day 9. I was overly concerned about the scenario where the rectangular areas ran along the edges of the larger shape. In the end, it was sufficient to check whether any edge of the shape intersected the rectangle.

Day 10 was the first and only day that I had to pull in another dependency. I used Microsoft Z3 to determine the required button presses given the constraints in Part 2. I wish I could say I hadn’t wasted a lot of time trying alternative solutions first.

On Day 11, I cracked and resorted to using Copilot to help create the solution for Part 2. I had worked out that the minimum state I needed to track was the number of paths containing either of the special devices. It was Copilot’s idea to use a bitmask to store that information efficiently. It also provided the algorithm for the device topology sort, so they didn’t need to be revisited during the search.

Copilot aided again in the solution for Part 2 on the final day, providing most of what you see in canFit. When looking at the solution thread before writing this, I was somewhat dismayed to discover that it wasn’t necessary to attempt to place the presents at all – just checking whether there was enough space under the tree would have sufficed. My solution runs in around 45 seconds, but I’m now left wondering whether the heuristic used to select the type of present would hold up under a more complex topology.

All in all, I enjoyed this year’s challenges, but I am glad to be able to resume my morning walks before work for the remainder of December!

Leave a Reply