I’m on vacation and I wanted to learn a new programming language. The easiest way to learn a new language is to practice it on something that has a goal. I looked for projects but couldn’t find anything appropriate that allowed me to focus on learning the new language rather than learning the project. Then, I found Advent of Code.

Advent of Code is a series of Christmas-themed programming puzzles, divided over 25 days. When the website opened in early December, it offered one new puzzle each day. Now, that December 25th has passed, all the puzzles are available.

The puzzles are almost real-world programming challenges, but they are hidden behind Christmas stories. For example, the first puzzle is:

Santa is trying to deliver presents in a large apartment building, but he can’t find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.

An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.

The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors.

For example:

(()) and ()() both result in floor 0.
((( and (()(()( both result in floor 3.
))((((( also results in floor 3.
()) and ))( both result in floor -1 (the first basement level).
))) and )())()) both result in floor -3.

To what floor do the instructions take Santa?

The puzzles are not extremely difficult but some of them are not beginner level either. They’re not appropriate for learning how to program if you’ve never done it before, but they’re great for learning a new language because:

  • They’re short enough so you can finish them in 30-60 minutes (most of them…).
  • They don’t require advanced language features.
  • They become progresively more difficult.
  • They don’t require any infrastructure (servers and such). Console apps are all you need.
  • They don’t have any technical restrictions.

The language I picked is Go. I was interested in it because I’ve used docker extensively recently and docker is written in Go.

After 25 puzzles, I have mixed feelings about Go. I like the fact that you do a lot of C-like coding and the learning curve is not steep, but the language itself has strange syntax and semantics. For example, a comma is required after each initialized field (even the last) but in other places like the imports declaration, elements are separated by a new line. Also, as someone coming from an OOP world, composition instead of inheritance seems strange. However, I really like the lack of implicit type casting between numeric types. It can be annoying at times but it prevents some subtle bugs. Kudos for that!

I had fun and finished all the 25 puzzles. You can find my solutions on GitHub, but before you go there, I suggest that you pick a new language and try to solve them yourself. That’s my challenge to you: learn a new programming language. You might like it, who knows? Even if you don’t like it, at least you’ll get exposure to a new world.

Not sure what to pick? Here are a few suggestions: Go, Haskell, F#, Python, Scala, Rust.

PS: My favorite puzzle was Day 23: Opening the Turing Lock.