I like Advent of Code – A lot

blog-image

The last three years I have done a lot of Advent of Code. It started 2019 when I took part in the local competition at the University. I did both that years and 2018’s problem each day almost for the entire month of December. I love both Christmas and this concept of small programming problems. I felt an urge that I just had to continue.

The summer of 2020 I did not have any internship or summer job. Instead, I worked on Advent of Code problems from 2017 and 2015. Through the summer I had great help from, not a coding duck, but in much the same way, my father. By simply explaining the problems to him, the complexity of the problem vanished. Disappeared. Or sometimes, just changed form. He is a mechanical engineer and of course helped me more than a duck. Especially on the math heavy days, but other days I think that even ducks would be of great help.

Along the way I have built up a list of similar problems I recognized between each year. So, I have been working on a library with generalized solutions that I can reuse. Now I thought I’d might share it with you. Not my code! But instead my list of tips and often encountered problems that might be beneficial to you on this year’s Advent of Code.

  • Always use longs. AoC likes to play with large numbers, so get in the habit of using long instead of int.
  • Vectors, both 2D and 3D, are a part of many tasks. Think of Manhattan distance, and different neighborhoods (von Neumann/Moore).
  • Find a nice parsing library that can extract sections and numbers. If you don’t like Regex, I’d look for some thing similar to C’s scanf.
  • Some form of path finding is almost guaranteed to be useful. I’d suggest taking a look at BFS, and maybe add a priority queue for speed.
  • Conway’s Game, or some cellular automaton variant, usually appears directly as a task.
  • If you played 2019 you remember writing interpreters. Think about optimizations or get used to debugging strange assembly.

But the most important tip I can give you is to have fun! There is no need to wake up at six in the morning to participate. And if one day is difficult, skip it and come back with new energy for the next days problem.

/Mårten 🎄❄️🎅