Advent of Code is just around the corner
For the past 8 years, developers around the globe have gathered together to solve daily puzzles from Advent of Code. And this year is no exception. So what is Advent of Code and why should you get excited about it? Let’s dive in.
Save the Christmas
Advent of Code, created by Eric Wastl, is an annual advent calendar that runs from December 1st to December 25th. Each day, you’re represented with a puzzle accompanied with a bit of lovely lore as the elves need your help saving the Christmas.
As an example, last year’s overarching story was gathering star fruit that Santa’s reindeer need:
Santa's reindeer typically eat regular reindeer food, but they need a lot of magical energy to deliver presents on Christmas. For that, their favorite snack is a special type of star fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.
These 50 stars are your rewards for completing 2 puzzles each day. 25 days, 2 puzzles each and a star for each successful solve.
The two puzzles of each day are related: you start with one and once you solve that, you get another one that is often a more complex or more difficult version of the first one. Sometimes the code you wrote in the first section is able to handle the second one no problem with tiny adjustments - sometimes you might have to completely rewrite the second for the second part.
Them puzzles
Advent of Code works by providing each user a problem statement and a (quasi-)unique input. To complete the puzzle, it asks you for an alphanumeric answer. Let’s take a look at the first puzzle of 2020 Day 1 as an example:
The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of Calories each Elf is carrying (your puzzle input).
The Elves take turns writing down the number of Calories contained by the various meals, snacks, rations, etc. that they've brought with them, one item per line. Each Elf separates their own inventory from the previous Elf's inventory (if any) by a blank line.
For example, suppose the Elves finish writing their items' Calories and end up with the following list:
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
This list represents the Calories of the food carried by five Elves:
- The first Elf is carrying food with 1000, 2000, and 3000 Calories, a total of 6000 Calories.
- The second Elf is carrying one food item with 4000 Calories.
- The third Elf is carrying food with 5000 and 6000 Calories, a total of 11000 Calories.
- The fourth Elf is carrying food with 7000, 8000, and 9000 Calories, a total of 24000 Calories.
- The fifth Elf is carrying one food item with 10000 Calories.
In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the most Calories. In the example above, this is 24000 (carried by the fourth Elf).
Find the Elf carrying the most Calories. How many total Calories is that Elf carrying?
Your job is to calculate the result - by any means you choose. You can write code with any programming language, do calculations with pen and paper, use spreadsheets or something else.
50 stars and so many ways to participate
I have never reached 50 stars. In 2020, I got to 15 stars with Rust. In 2021 I made a record with 45 stars with Python and in 2022 I got to 38 stars with Python. Globally, last year almost 290 000 people achieved one star on day one but less than 13 000 of them reached 50.
What I’m saying here is that the worst way to “play” Advent of Code is to stress about the stars.
There are many ways to participate in Advent of Code and finding the one that is most fun for you is important:
Some people compete in the leaderboards. The leaderboards are based purely on speed and you need to be very experienced puzzle-solver with usually a good setup to make it close to the top. It can be very rewarding though.
Some people learn new languages or technologies. This has been my approach in the past. 2020’s Rust and 2021’s Python with Jupyter Notebooks were that. The puzzles are well defined and don’t require any advanced language features (although you can use them) so they are great for learning.
Some people use it to teach. My last two years with Python and Jupyter Notebooks have been an exercise in technical writing and teaching, with an added bonus of actually helping people learn.
Some people hone their base skills. You solve problem after problem, using their base programming skills to gain confidence and strengthen those skills.
I love the community
What I truly love about Advent of Code and what brings me back to it year after year is how it brings together developers from different communities.
The way these puzzles are set up makes it possible for people from different communities to come together, participate and discuss. Pretty much every developer community I’m in has something for Advent of Code. Usually it’s a channel in Slack or Discord or forums where people can share their solutions, ask questions and discuss.
I’ve learned so much from other people’s solutions and it boosts my interest in solving these because I know I get to chat about them with others who are excited too.
Advent of Code can also be a great companion to starting technical blogging. You’ll get 25 blog posts worth of puzzles to write about so you don’t need to worry about coming up with ideas.
Tips for those who want to start
If you got interested in Advent of Code or are a returning participant, I have a blog post from two years back sharing my tips for Advent of Code.