Last year I found out about Advent of Code.

You said what?

Advent of Code by Eric Wastl happens every year since 2015, every December from the 1st to the 25th. Each day there’s a new programming challenge1 split into two parts. The first part tends to be easier than the second one. The second part usually builds upon the first one, being a follow-up task that requires more steps and/or with a higher degree of complexity. You can’t always reuse the bits from the first part to solve the second one though.

For those familiar with programming contests like ACM ICPC or OBI, or online judges like SPOJ or UVa, advent of code feels like home. The main difference is that there is no time pressure and no need to write spaghetti and unreadable code; in fact, writing readable and elegant solutions is encouraged (citation needed…).

For those familiar with FAANG/Tech whiteboard interviews, advent of code feels a lot like a typical interview. I would even go further and say it’s a great way to practice for interviews.

It is a great moment to either (i) learn a new exciting programming language or (ii) improve your mastery on programming languages that you already know. I know several people (see below) that used AoC2 to learn Rust or Kotlin or whatever else was exciting for them at the time. It’s surprising that the official Kotlin Docs even contain a section called Advent of Code puzzles in idiomatic Kotlin.

Some folks go even further and use it to practice their code golfing3 or even Google Sheets skills. I have a deep amount of respect for them as it’s quite a challenge. If you think it stops there, I’ve also seen solutions in awk and sed.

Another positive aspect of AoC is that it has an integrated dashboard that tracks your progress as you go. It’s a simple element of gamification that immensely improves motivation and fun. You really feel a big desire to collect all those 50 stars…

What about me?

My goal for 2021 was relatively less ambitious than that, I just wanted to improve my Python skills, more specifically Python 3. I learned Python 2 during my first year in university and used it sparingly at work and for personal endeavours, but always had a knowledge gap in Python 3.

I set up a public git repository with my solutions and aspired to write simple and elegant python, my only constraint was to limit myself to what is available in the standard library of a vanilla python3 installation in Alpine linux, with the exception of numpy which is widespread enough to deserve an entry in my requirements.txt, and of course devtools like debuggers, linters and auto formatters as needed.

As an additional, non-programming challenge I also limited myself to only use the command line. This basically meant no IDEs4. My programming environment was ultimately ssh to an Alpine Linux VPS + tmux + vim. To make my life easier, one of the first tasks I accomplished was to write a generic Makefile to help me test and run my scripts. A typical invocation would look like:

$ make DEBUG=1 DAY=3

…whereas I could choose between the sample input versus the real one with DEBUG, and the puzzle day with DAY.

Was the experience worth it? Definitely yes! Even though I only completed ~8 puzzles out of the 25 ones due to having my attention split with another project I was working on at the time, the thematic submarine puzzles were hella fun and I learned a lot of python 3 on the way.

A few highlights of what I learned and used from my python 2to3 transition were f-strings / string interpolation (print(f'The sum is {sum}')), “everything is an iterator now” even map and range, the standard library is awesome and sometimes you stumble upon useful abstractions like Counter and defaultdict, sort is different now (key instead of comparison function), this pdb debugger thingy, among other topics I can’t remember at the moment. I realized the only concept that was previously familiar was the different syntax of the print function (you have to use parentheses now).

In terms of workflow, I also learned that virtual environments are now supported natively5 (python -m venv), direnv is an amazing tool to automate/manage environments in git repositories and also happens to have first-class python integration, pylint and autopep8 are good integrations with vim to help spot basic errors and/or suggest best practices, and numpy takes forever to build from source.

What about the community?

AoC enjoys a lot of popularity and zeitgeist, especially during times of the COVID-19 pandemic, but even before then. There’s a large /r/adventofcode subreddit community, lots of people share their solution snippets and impressions on Twitter (#AdventOfCode), there’s a ton of public git repositories on GitHub where people share their coding solutions, in pretty much any programming language you can think of, and finally there are many screencasts on YouTube. The Internet in the 2020s sparks creativity in every unimaginable corner.

There’s so much information that it’s impossible to stay on top of everything. Here is a small list of repositories that I followed this year, most of those are acquaintances/friends and/or stumbled upon Twitter:

C++:

Python:

Rust:

I find it’s really constructive and useful (and also fun) to peek at other people’s solutions after I coded my own. I have extensive (albeit kinda rusty these days) experience with C++ so I wanted to follow at least one repository coded with it; since I wrote my solutions in python it was also a natural choice to follow a few python repositories; and, finally, I wanted to peek at some languages I am not familiar with to get a gist of them. This year I watched Rust and a few bits of Clojure and Kotlin on Twitter.

Finally, for some extra inspiration, there are also some 10x programmers6 out there that seem to be fans of AoC as well: Peter Norvig and Russ Cox (rsc). There are probably several others I am not aware of.

Final remarks

I am hoping to participate in AoC this year (2022) as well, and possibly revisit the 2021 puzzles and resolve the rest of the ones I missed as time permits.

Hopefully this post encourages and motivates you to try Advent of Code as well! Happy coding.


  1. Or puzzle, if you will. ↩︎

  2. Acronym not to be confused with a certain annoying^W politician. ↩︎

  3. For those unfamiliar with the concept, code golfing is all about writing a correct solution with the fewest amount of characters. ↩︎

  4. For example: PyCharm, and also VSCode, which is getting so big these days I don’t even know if it’s possible to just call it a simple text editor anymore. ↩︎

  5. Back in the days, virtualenvwrapper was all the rage. ↩︎

  6. The 10x programmer thing is a well-known joke however in this instance the mentioned characters are indeed superb programmers that I immensely respect. ↩︎