DEV Community

Cover image for What I learnt from Advent of Code 2021
Wen Jun
Wen Jun

Posted on • Updated on

What I learnt from Advent of Code 2021

Advent of Code (AoC) is a yearly coding challenge in the form of an Advent calendar. Every day from Dec 1 to 25, a small programming puzzle is released and hundreds of thousands of people attempt to solve the problems.

As this year’s Advent of Code comes to a close, I wanted to reflect on my AoC journey thus far.


I first attempted AoC in 2018. However, I was somewhat “under levelled” back then, as I did not have much experience in object-oriented programming or data structures and algorithms. Since then, I have accumulated much more experience and taken modules that helped refine my computational thinking and hone my programming skills. As a result, I was much better equipped to tackle the challenges this year and managed to achieve all 50 stars by Christmas.

Advent of Code Calendar

Technical aspects

I found that the difficulty level of this year’s puzzles scaled somewhat linearly, which made for a very enjoyable experience. My friend and I remarked that "the difficulty creeps up on you, and you only realise how far you’ve come when you look back at your solutions from a week ago, or even a few days ago". From Dijkstra’s algorithm to the Inclusion-Exclusion Principle, I was certainly challenged technically.

For a more detailed rundown of notable problems, check out my other article: Notable problems from Advent of Code 2021.

Non-technical aspects

I found that I learned more in terms of non-technical aspects than technical ones.

It’s all about the community

My sister told me that her biggest mistake in university was “trying to do it alone”. I tend to be an individualist, but her advice resonated with me during this year’s AoC.

During the pandemic, I found it harder to feel a sense of belonging and it was something I craved. For example, I missed the feeling of being physically in the same room as my classmates at school.

Advent of Code subreddit

After solving each problem, I would reward myself by visiting the AoC subreddit in search of memes, cool visualisations and other people’s solutions. Reading about everyone’s experience and approaches to the problems contributed greatly to me feeling like I belonged to a community of like-minded people.

It also helped that I had friends who were also participating in AoC. After we had independently solved the day’s problem, we would discuss and compare our approaches and code.

Dealing with imposter syndrome / fixed mindset

One issue I remember having in 2018 was imposter syndrome / having a fixed mindset. I’d struggle through the problems with my limited knowledge of data structures and algorithms, and then I’d come across a solution that was far cleverer or more efficient than mine. My response to this would be to berate myself with “Ah dang, why didn’t I think of that?”, when a more reasonable response would have been “I still have lots to learn. What principles can I pick up from this solution so that I may come up with something like this in future?”.

This year, I was able to come up with better solutions, although they were not the fastest, nor the shortest or the most elegant. Moreover, I was better able to deal with imposter syndrome and could switch to a growth mindset more easily, which is a testament to my personal growth since then. As a result, I could read about what others had done and learn from them.

Know your purpose

Do it for her meme

AoC is many different things to different people. Some do it to learn a new language, or just to practice. Others take a more competitive route and make use of features like the global leaderboard or the private leaderboard.

Although I had not decided what my purpose was when I first started AoC, I did eventually distil out a few points through some soul-searching during the last week.

I’m doing it:

  • For myself
  • For fun
  • To practise object-oriented principles
  • To practise writing good quality code

Equally importantly, I’m not doing it:

  • For the leaderboard
  • To get the fastest solution
  • To get the shortest solution
  • To compete with my friends

These principles guided my behaviour; I focused on writing clear, concise code that communicated the computational processes well.

In particular, “for fun” allowed me to make better decisions about when it was time to get some help. I did this on two occasions.

Day 22: Reactor Reboot

My approach for this day involved implementing functions based on the Inclusion-Exclusion Principle. After spending 3 hours implementing it, I realised a fundamental flaw in my algorithm. I suspected that my approach of using the inclusion-exclusion principle was not wrong, but I could not figure out how to fix or work around the flaw. I eventually checked the Reddit megathread and found someone who had used a similar approach. From that solution, I was able to understand the proper way to apply the principle to the problem. To make sure that I fully understood their solution, I re-implemented the algorithm without referring to their solution and was able to solve the problem.

Day 24: Arithmetic Logic Unit

This was a bizarre problem. I had re-implemented the ALU as the instructions seemed to imply I was supposed to but was faced with the prospect of having to brute force 914 possible values. I tried reading the instructions in the puzzle input and running them by hand, but gave up after a few lines as I didn’t think it would lead me anywhere. This was my first time feeling completely lost on where to begin tackling a problem.

I was distinctly not having fun, and rather than continue bashing my head at the problem, I decided I could justify turning to Reddit for a hint. The first small hint did not help much, at which point I dived into the solutions megathread. This was a good move as it turned out that this problem required a great deal of reverse engineering, far more than I was expecting. I did eventually repeat the steps of reverse engineering on my own and write a script to solve the problem, just to prove to myself that I did understand it. I learned from other Reddit users that most years have at least one problem that requires reverse-engineering the puzzle input, so perhaps I will be better prepared next year, with this knowledge.

Beyond a certain point, the chances of me coming up with a solution on my own become rather slim. Turning to Reddit for help on these two days allowed me to keep AoC a fun experience (which was my purpose), rather than a painfully mind-bending one.

Closing Remarks

A month ago, I never would have thought I would finish all 25 days of AoC, (mostly) unscathed, and I’m very happy to have made it this far.

I am incredibly grateful to Eric for putting in the effort to create such a fantastic challenge for the AoC community every year. I learned a lot from the past month and, most importantly, had lots of fun while doing it. I will miss jumping out of bed in the morning to refactor my previous day’s code. Perhaps next year, I’ll attempt AoC 2022 using a new language (Clojure? Go? C?) / library (NumPy) I’ve always wanted to try or get better at.

That being said, I am glad it’s over. I could start to feel myself getting burnt out towards the end as I spent up to 6 hours a day stuck on the same problem. I look forward to a good break from AoC over the next few days.

Top comments (0)