Reflections on 10 days of 'Advent of Code'
chat, i'm locked in
“Advent of Code is a is an Advent calendar of small programming puzzles for a variety of skill levels that can be solved in any programming language you like.”
— Eric Wastl, Creator of Advent of Code
I first heard about Advent of Code in December 2022 when a club on my campus set up a local leaderboard. I completed a whopping two(!) days that year. Yeah, two out of twenty-five. Real stuff. I remember that day 1 and day 2 were easy. Even day 3 looked easy and I quickly implemented a naive solution but when I ran it, it just didn’t stop running. When I mentioned it to the other club members, they mentioned that I had to use ‘breadth first search.’ That is in air quotes because I did not know what that was. I promptly abandoned it, partly because I had exams and partly because I just couldn’t be bothered. I was close to the bottom of the leaderboard anyways. December 2023 came by and I just watched some videos of people talking about it but I didn’t even take a look at the questions. I had exams. Also, I couldn’t be bothered.
As December approached this year and I saw people start talking about it, I decided to give it a go. I guessed that by day 7 or 8 I wouldn’t be able to solve the problems or, at the very least, I would find them very difficult. I also decided to solve them using C++ because I am trying to learn C++. I have used C extensively though. I am also using Supermaven, an AI code completion tool.
Success so far
I am actually surprised at the progress I have made so far. I completed day 11 this morning after a lot of headaches but for the most part, my solutions have been mine. I had to visit r/adventofcode on day 7 to look for better solutions and I discovered that the way I was checking for loops was wrong. So I went back to my code, made some changes and got them right. I also needed help on today’s (day 11) problem. I initially implemented a naive solution and it worked fine for part 1. But in part 2, the problem grew and my program ran forever (no really, it’s been running for more than 8 hours now). Of course I went to Reddit again and people were mentioning recursion. I didn’t necessarily see how that was supposed to help, then I watched a Youtube video. And as the person was explaining the question, the solution came to my mind and I went to solve it and I came up with a solution that ran in less than 0.2s. Now, that is crazy. This is another dimension of the surprise for me: I’m not just solving them, I’m solving them in good times. My time on day 6 was ~11s, day 7 was ~5s, day 9 was ~3s, and day 11 as I mentioned above was ~0.2s. All the other days completed in less than 0.03s(!) A good question to ask is what are the normal times. I am not really sure although Eric says on the website that all problems should get solved in less than 15s. That is likely just a large upperbound. I am just comparing against the baseline from two years ago. Low bar to cross I know, but I am clearing it nicely. Or it could just be that Advent of Code is easier this year (shh, don’t say that out loud).
To be fair, I have taken multiple algorithms courses between December 2022 and now so if I was not doing much better, that would be terrible. But another thing that I observed is that I am not thinking about ‘breadth first search’ or other algorithms. I am just looking at the problem and thinking up a nice solution. I end up with breath first search or dynamic programming algorithms but I didn’t think of them by name. That suggests to me that I have internalized some of the inner workings. That is why those ideas come to me freely.
Gains and un-Gains
My biggest gain so far has come from just implementing the first good idea that comes to my mind and then straightening it out as I code. In my algorithm courses, I would have a problem that had to be solved in say O(n) time. Whenever ideas come to my mind that are not in O(n), I would just ignore them and keep pondering till I come up with a solution. This carried over to my coding. Whenever I need to do something, I would spend a lot of time pondering on different approaches, and I would discard every solution that did not feel neat in my mind. In the past 10 days, I have greatly improved my ‘time-to-first-type’ and this is a big gain for me. Of course, you should think about your code before you write it but at some point you should just start writing. Don’t start pondering whether a string or an integer representation of the data would be faster. Just write both of them and time them.
I am also building an appreciation for limits. I’ve seen many leetcode problems where the inputs are bounded. Say 1 < n < 1,000 for example. But this has never affected how I solved the problem. Probably because the limits are arbitrary, or the test cases don’t test at the limits. Or maybe I’m so good that I always implement the best solutions first (not true btw). But during this Advent, I’ve had to think along the lines of ‘If I implement this algorithm, I’ll have a list of order ~2^25. That doesn’t seem right.’ I have also gotten burned by C++ types a couple of times. Int? yeah that’s too small, you’ll want an unsigned long long to handle this (I mean int64 might be enough, but why not go all in). I must say, it feels good to work at the limits.
I also started streaming on day 9. It’s all scuffed for now and I am not even sure if it will last beyond Advent but it’s going ok. Currently going live daily at 12 am EST
Any un-gains? The only un-gain I have noticed is not from Advent of Code itself, it’s from using the AI code completion. I am definitely moving faster, but at what cost. Whenever my network goes down and the completion is slow I find myself just staring — not knowing what to write. Of course I know what to write, or do I? The completion does not give me the solutions obviously, but it helps with the language. But it might be making me dependent on it. This may be fine, I may all end up using this everywhere in the very near future. I mean I use code editors and LSPs, AI completion might just become part of that. Apart from that, it also makes many pernicious mistakes. They tend to look correct but end up being wrong in a slight way. For example, it might check if a point is out of bounds instead of checking if it’s inside. This feels like nothing but it might lead you has led me down debugging routes that are completely unneccessary. It might just be a skill issue on my part and I own that. But I will stop using it for a while to see if it makes any difference. I will keep using the chatbots though.
Conclusion
Doing Advent of Code till failure is a good idea. Even till after failure, just watch a Youtube video and reimplement the solution on your own. It’ll really help (I think?) At least, that is my plan for this Advent.



Nice work 🥂