Advent of Code 2022 Thoughts and Favorites

This year, I was introduced to Advent of Code, a series of 25 puzzles released nightly starting December 1, by a couple of friends and we had a friendly bit of competition doing the challenges each day. I wasn't sure what to expect but it ended up being a challenging, engaging, and fun activity to do each night leading up to Christmas.

Each day you are presented with a two-part challenge that is vaguely Christmas-themed. They tended to start off fairly easy with the difficulty ramping up through the month and with a couple that were much more challenging than others. The first part usually helps you understand the dataset for the challenge and how to work with it, while the second part extends, remixes, or elaborates the calculations you did in the first part. The solutions to all of the puzzles are simple numeric or text answers that are easily checked and players are given different datasets so someone else's answer won't work for you.

I chose Python to solve most of the puzzles in because I had been working with it a bit recently and the data-oriented puzzles seemed like a good fit for the general language features. A couple of times I used C or something else because I just thought I could get the answer quickly that way, but I went back later and added a Python version for those as well.

Most days I put together a quick-n-dirty solution to get the answers entered, then went back and cleaned up my code just a little bit before committing it for comparison with my friends. Amongst our group, half of the players finished all of the challenges, while a couple just didn't have the time to work on them each day but still made it through a good portion of it. On average overall, I was about the 3800th person to solve each day, ranging from 13122nd down to 342nd.

Fastest Solution Days

Day 18 and Day 21 had my fastest Part 1 solves and Day 6 was my fastest Part 2 solve, but Day 22 had my fastest relative to other players. I think some of that was getting into the groove of how the problems were structured and also the variation in difficulty from day to day.

Day 18 was interesting: given coordinates of individual voxels, Part 1 had you calculate how many faces were exposed. I had a solution to this in a little over 4 minutes. Part 2 though had you remove all of the interior faces that were not somehow exposed to the outside. This ended up taking another 2 hours to figure out, ending up as one of my slower solves.

Day 22 was definitely one of my favorites. You had a map that was flat in Part 1 but ended up needing to be folded into a cube in Part 2. I ended up making a cube out of some scraps of wrapping paper and folding it up to figure out all of the coordinate transformations needed to make it work.

Wrapping paper cube with numbers on each edge used to help solve Day 22 quickly.

Frustrations

A couple of days required doing some path searching across large grids. With naïve methods, these could run for many hours to get the solution, some would have required gargantuan amounts of memory. These required a lot of thinking about what could be used as culling criteria, making sure all pieces of information were used correctly, and sometimes figuring out patterns that repeated over numbers of cycles. These could get incredibly frustrating, but also helps you keep in mind that some things really do have to be optimized well to work at all. It'll be something I remember looking at problems next year.

Speed

I did learn a couple of tricks to get my solutions as quickly as I could figure them out. I made a template of my basic code that I used to pull in my puzzle input each day which I would copy and prep the directory for ahead of time.

I also discovered the excellent advent-of-code-data Python module which makes it a single line to pull in the daily input in one of a couple of formats. This saves the step of downloading the file and getting it to the right place for the code to pick up.

Overall

I found it to be pretty addictive and I definitely wanted to complete the puzzle each night. Early in the month I had some last minute travel for work and coming home late one night I finished the Day 9 puzzle sitting in the baggage claim of the airport waiting for my luggage to show up. Luckily it was a fairly quick one and my luggage only had to go around a few dozen extra times!

It was a great experience and I definitely plan to play again with a friendly competition group in 2023. I also see myself going back to do some of the previous years as well for some extra fun. Highly recommend if you like programming and puzzles!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.