Some tips about participating in Advent of Code.
AoC is not a competition
If you were to go with online opinion, AoC is all about getting the solutions as fast as possible. This is actually not true, apart from the top 100 scorers every day[1]. Many people post their full solution online on the AoC subreddit as soon as the top 100 slots have been filled. So if you want to get 50 stars, you pick a popular language (like Python), hang out in the solutions megathread, and run the first posted solution on your input to get the correct results.
If your organization has a “competition” where the top scorers in their leaderboard get some reward, don’t participate. It’s too easy to suspect someone of “cheating” for it to be fun.
Instead, focusing on using the event to expand your skills.
You don’t need to finish each puzzle the day it is released, or within the 25 first days of December
The puzzles can be completed at any time and in any order.
Don’t let trivial mistakes trip you up
In almost every puzzle, your personalized input will be provided as a text file. Set up your environment to deal with this consistently.
For example, for every puzzle, I make a new subdirectory. The puzzle input goes into a file called input.txt
. The example input goes into another file, test.txt
. I then open a new file for my code, and enter a canned template that reads the content of a file into an array, one line per entry. It takes care of newlines and carriage returns (but preserves empty lines).
Then, when it comes to dealing with the input meaning, I can operate on an abstract array instead of a file.
In a similar manner I also set up some modules for dumping variables, running simple tests, etc.
You can see my (Perl) template here.
Use the examples
The puzzle text is clearly written, and any questions you might have regarding the rules of the puzzle are answered in the text or in the example. Once you get the example to run correctly, it’s generally just a question of changing the in-data to “live” to get your answer.
Generally. At higher levels there can be “twists” in how the real data is presented as compared to the examples. Also look out for edge cases. The example data might not include negative numbers, but the real input does. Have you taken that into account?
Puzzles start out easy but get harder
And weekends are generally tougher than weekdays.
Some problem classes tend to make an appearance every event
These include
- Conway’s Game of Life
- Register Rodeo - this is my term for a class of problem where you’re given a long list of statements, some of which are data and some of which are instructions, and you need to decode them
- pathfinding through a maze
- finding the lowest cost for some complicated series of actions (generalized Dijkstra’s)
Having a basic knowledge about these is beneficial, but not required.
Remember to have fun!
[1] if you want to try to crack the top 100, this guide is not for you.