I Did The Whole 2024 Advent of Code And All I Got Was This Lousy Blog Post

Look on my works, ye mighty, and despair.

And all it took was most of my free time and my sanity between the 1st and 25th of December. But I a) accomplished something that counts for hefty bragging rights in the very specific genre of nerd circle I run in, and b) was surprisingly educational. So here's some of the things I learned, in no particular order:

Have a good scaffolding and standard library

...even if you have to write it yourself. A lot of the Advent of Code problems start with extracting a bunch of integers from a bunch of strings. I wrote StringUtils.ExtractIntsFromString() once and used it 27 times (more than once per day!) in my solution. This saved a lot of hand-rolling input parsing code. A lot of the problems involve some kind of thing happening on a grid of points, often involving some sort of robotic reindeer or whatever moving around. My GridPoint utility class let me abstract so much of that logic away from the actual problem-solving code. I also defined a function called, literally, D() (for Debug) that I could call from anywhere in a problem context to instantly print to console output -- you might be shocked how often printing program state worked better than setting up an actual debugger. The more you can move the common abstractions out to their own components, the more time you can spend on actually solving the problems each day. Which is nice because...

The silliest things can take way too long

I'd love to be one of those cool l33t coders who gets on global leaderboards by submitting a solution 3 minutes past midnight EST (when it drops) every day. But I value my sleep, and I'm also a mere mortal, which means about a third of my time on most problems involved trying to figure a way to solve it with an algorithm, and about two-thirds trying to structure my for-loops so they incremented the correct way or whatever. I think this is maybe one of the benefits of doing something like this every day for the better part of a month - by the end of it, you really start to be intentional about what you name your variables, where you're going to debug a fiddly little bit of program state that you're worried you set up wrong, how to factor your code to keep the file organized as you keep adding more stuff to it, etc. And all that's great because...

You might think you know a lot about algorithms, but there's so much more to know

I'd have rated myself, before I did 25 days of often diabolically tricky coding puzzles, as "someone who knows a lot about algorithms and data structures". And I'm so glad I knew how to use a hashset in battle, and I'm so glad I already knew what Dijkstra's Algorithm is and (roughly) how to implement it, but I used just about every piece of that knowledge, and still regularly found myself at or beyond the boundaries. There were at least 3 separate days where I ended up stumped enough to go to the subreddit where I stared in dumbfounded incomprehension at other, smarter, people's code until I could piece together how it worked well enough to write something that worked myself. I learned a lot doing this, actually! Even some math! So overall, even though there were definitely points where the time I spent staring at my laptop muttering to myself on a Saturday morning started to irritate the people around me (sorry!), I'd say it was a worthwhile exercise. Not convinced I'll do it again next year, though.


You'll only receive email when they publish something new.

More from Tom
All posts