Advent of Code

It’s that time of year again. Every morning I wake up excited to open my advent calendar, in which resides a beautifully constructed programming problem that must be solved before work. I must help the elves save Christmas, that’s my morning mantra.

What is Advent of Code?

Advent of Code is an annual bunch of programming challenges, where each day, starting on the the 1st of December a new 2-part question is released. There are a possible 2 stars up for grabs every day, 1 for each of the parts. They are, of course, Christmas themed, usually around helping the elves do something or other in order to not ruin Christmas for the masses.

The challenges get more difficult as the days go on — or at least I think they do, that or my motivation wanes.

The image below stolen from here shows the completion statistics for each day of 2020. The gold stars represent the users that have completed both parts of the puzzle whereas silver means they only completed one. Each star represents 4586 users.

So, if my maths is correct, that’s a total of 13,748 users completing the last day compared to 169,682 who completed the first, that’s quite a significant drop off.

Complexity represented in stars completed advent of code

What’s the point?

Whether you’re a seasoned professional or a new programmer, Advent of Code will help you brush up on your skills and think about problems you wouldn’t usually come across in your day-to-day endeavours. There’s no better way to sharpen your problem-solving skills and get into the Christmas spirit — maybe even have some Michael Bublé on in the background.

If you want to learn a new programming language now is the perfect time! I often solve the challenges using a number of languages, in a number of environments. Last year, I solved some in C#, JavaScript and even one in Prolog. You’re simply given an input and you provide the website with an output. Any language will do, use your own tooling, solve the problems in your own editor.

It’s also a lot of fun, there’s nothing more satisfying than completing a problem you’ve been struggling on.

What if I can’t solve a problem?

If you get stuck and your puzzle input isn’t giving you the correct answer, make sure you setup some tests and use the practice input provided. Usually the practice input will include all the potential quirks of the problem. If you’ve got a test that runs the practice input and gives you the expected answer, chances are your solution will run the actual input just fine.

If you do enter the wrong answer, Advent of Code will let you know if you’ve entered a number that is too big or too small, so remember to jot down this value so that when you make some changes to your code if the output heads in the correct direction, you know you’re on the right path — I tend to plonk the numbers in a comment, something like:

// 543523 too big

If you’re still stuck, I’d recommend writing your own test cases. Prove your code works, practice TDD.

If you’re making no progress, talk the problem through as though you were explaining it to someone with no knowledge, think of the issue from a high level, have a go at Rubber Duck Debugging.

If you’ve got colleagues or friends that are participating, maybe ask for their help, chances are they solved the problem very differently to you and could provide some insight.

Lastly, there’s a really good subreddit that could be of use, chances are someone else is struggling with the same issue you’ve got. But try not to copy someone else’s code, modify your own.

My biggest tip

Auth0 have a pretty awesome blog giving their own tips and tricks. My main tip would be to use an IDE, use an environment that you’re comfortable with.

This year I’ll be using Rider by JetBrains to solve the challenges in C#. Coming from a Java background where most of the work was done in Intellij, I’m very comfortable in this environment. I can easily add a unit test to verify my thoughts in a matter of seconds, I can debug, evaluate expressions at run time, add conditional breakpoints, jump into the .NET core source code and much, much more that I probably take for granted.

Awesome side-note, JetBrains are sponsoring this years Advent of Code, which just shows what a brilliant company they are. They’ve also got a really good YouTube video if you’re interested in solving the problems in Kotlin.


If you’re the competitive type, you can wait up until midnight EST/UTC-5 and get hacking as soon as the question is released. Lots of people take Advent of Code quite seriously and participate in the speed contest to get themselves on the leaderboard, where you can link to your GitHub or show that you’re an Advent of Code supporter.

The leaderboard is relatively simple, if you get a star first you’ll get 100 points, second is 99 points, down to 1 point at 100th place.

If you’re just looking to challenge yourself, I wouldn’t worry about this, I tend to tackle the challenges a good 10+ hours after they’ve been released, so don’t be looking for me in the top 100!

What about you?

Are you competing in Advent of Code this year? What’s your goals? Expect to finish all 25 days in 25 days, or would you be happy with solving just the 1st day? Let me know.

Each year Advent of Code gets more and more popular, with big companies like JetBrains, Shopify and Ahrefs on board, they’re doing something right, so a big thank you to Eric Wastl for creating it.

I hope you enjoyed this blog, don’t forget to sign up to the newsletter – Be the first to hear when we release new content, participate in weekly coding challenges, listen to more of my drivelling.

One comment

Leave a Reply