Advent of Code - advice for rookies

The Advent of Code will begin on December 1.

What advice do you have for those participating in the Advent of Code for the first time this year?

2021 was my first experience with AOC, and I wish I had developed a set of helper functions to read test data in several different formats, so I didn’t have to reinvent the wheel for each challenge.

I aim to solve each problem on the day it is released, but I won’t stay awake to get the challenges when they are first released.

  • Some people like working on a prior year to get ramped up.
  • Tooling around downloading and reading inputs is helpful. I have a script that spits out a stub file for each day. My tooling also submits solutions for me. You can write or own or borrow from others :slight_smile:
  • Weekend exercises are harder than weekdays.

My advice is more tailored for non-competitive people, which I imagine is the majority of people doing Advent of Code:

  • Success in Advent of Code is ultimately measured by the amount of things you learn - Doesn’t matter how faster other people at doing the problems than you or how far behind you are. If you are learning stuff, you are doing great. ericwastl’s related tweet

  • Have fun - Always remember to have fun! Advent of Code is a great event for that. Write bad code - you are not pressured to write great production code. You can write code that barely works, it’s fine. But also, write good code if that’s what you are into. Write code that is good and bad at the same time. Try new things you wouldn’t try normally. Have fun!

  • It’s ok to struggle - The difficulty increases as the days progress. Depending on one’s experience and background, there will be a day you will struggle to solve. It’s ok. You can skip the problem for that day and come back later, or you can take extra time to figuring it out. Don’t be too hard on yourself if that happens, the important thing is to not give up and see the challenges as learning opportunities. ericwastl’s related tweet

  • Problems have 2 parts - Part 2 is only unlocked after you do part 1. Do both parts to get 2 stars for that day! Sometimes beginners to Advent of Code miss there’s actually a part 2 for the problem and call it a day after solving part 1.

4 Likes

AoC can be a lot of fun (for some definition of fun). You can just enjoy solving a puzzle, you can explore data structures and algorithms, you can use it to learn a new programming language, you can try to solve a problem as fast as possible, you can try to create extremely fast solutions. Your actual goal is up to you.

You might want to subscribe to Reddit’s /r/adventofcode. AFAIK that’s where the AoC community comes together. A few minutes after each puzzle has been published a “Solution Megathread” gets unlocked and people start posting their solutions, in all sorts of programming languages and in all kinds of styles. Some even post videos of themselves reasoning about, solving and explaining the problem. It can be cool to watch how some do that while still getting on the global leader board.
This community also has its own “culture”. There are solutions in programming languages that no sane programmer would deliberately choose, just because it’s fun and can be done. Some “raise the stakes” and make the problems harder by adding/changing/removing some requirements. There are visualizations, memes, and comics.

Each problem usually has some motivating text that’s part of the overarching story, an explanation of the puzzle, and an example. That example can be used as a test for your solution, and I strongly recommend doing that because an invalid answer results in a time penalty (and because I’m a strong believer in automated tests).

If you want to solve an exercise as fast as possible and maybe even be one of the first 100 to do so, prepare a little bit. Write a script that downloads the input. A single invocation of curl will do, use the “inspector” of your browser to get that command (including the required cookie) and modify the URL to match the current day. Some (like @IsaacG) automate that process even further and submit the solution programmatically. You can find these kinds of setups on GitHub.

Each year has been completely different from the others but some themes are re-occurring and therefore some facilities/libraries will come handy. If your programming language does not have built-in support for arbitrarily large integers you will need a library to handle them. A heap (a.k.a. priority queue) and a Disjoint-Set data structure (a.k.a. Merge-Find or Union-Find) are useful to have. You might also want to brush up on some fundamental algorithms, e.g. the “A*” path finding algorithm.

And finally: Don’t get too frustrated if you’re slower than others or fail to solve a particular puzzle. This competition attracts some experience competitive programmers from around the world. If you keep working on these puzzles each day you will get learn new techniques, you will get used to applying them, you will be able to solve the puzzles better and faster. And isn’t that alone a great thing?

4 Likes

I usually expand on the learning experience by also making sure I try to read and analyse other’s solutions.

I haven’t yet found a day that I haven’t learned something, or been perplexed by a solution that is too clever for me at the moment.

3 Likes