What’s behind door number one? A coding challenge, of course!
As the end of the year draws nigh, programmers’ thoughts turn to the Advent of Code. Running since 2015, the site celebrates December holidays and coding, with a collection of daily challenges.
How Does it Work?
The Advent of Code site is text-heavy, with green links and an overall presentation that mimics a text editor or terminal session.
Every day, from the 1st of December until the 25th, a new challenge becomes available. Each challenge is clearly described, with examples and any relevant input files available to download. There are two tasks per challenge.
Each task will ask you to enter a final answer, which will be something your program should have calculated. You can use any language you want to complete the task. In theory, you can work out some solutions by hand, but this will usually be laborious—and where’s the fun in that, anyway?
How Do You Take Part?
- Start by logging into adventofcode.com, using any of the OAuth services that the site supports. The most obvious service to use is GitHub, the collaborative open-source platform. You can also use an account from Google, Twitter, or Reddit.
- Go to the daily task. If you’re late to start, don’t worry; you can always complete tasks from previous days to catch up. You should definitely try to work through each day in order, though.
- As with any task, exam, or interview question, you should read the instructions carefully! There will usually be important details you need to note in bold, white text.
- Download any required data files.
- Write your solution in any language you choose. You might even be able to solve some tasks using standard Linux command line tools.
- Once you have your solution, enter it in the box at the bottom of the task. After completing each day’s first task, there will be a second to stretch you further.
What Are the Challenges Like?
The challenges start simple and get more difficult as the month progresses. This year’s first task is simply to add some groups of numbers from a text file and work out the largest total.
A task might seem straightforward to begin with, and you can ‘brute-force’ many, especially the easy ones. However, because the challenge lets you use any language, and only asks for a final answer, you can get whatever you want out of it. For example, you might want to use the series in one of these ways:
- To learn a brand-new language from scratch.
- As a ‘speed’ test, to see how quickly you can solve each task.
- To test yourself with a different language each day.
- To see how efficient a program you can produce, either in how fast it runs, how little memory it uses, or how few lines of code it contains.
- As practice for writing the cleanest, most readable code you can.
All the challenges are part of a wider theme, typically relating to Christmas. This year’s story is about Santa’s elves gathering fruit to sustain them during their busiest work period.
Learn by Challenging Yourself and Having Fun
The web is full of programming games and challenges you can take part in. They may not always produce practical results, but they offer a fun break from day-to-day work. And interesting tasks are often easier to see through than mundane ones.