Advent of Code 2022

David Wagner

Since 2020, every year I solve the Advent of Code puzzles. This post, like those of previous years, is an experience report of my 25+ day journey in December.

Spoiler alert: If you’re still working or planning to work on the puzzles stop reading now.


Between December 1 and December 25, a programming puzzle appears every day at Advent of Code website. Each problem has two parts, the second part unlocks after you complete the first. To understand each day’s puzzle, go to the website and read the full description (for example Day 1: Calorie Counting).


In previous years, I used the Advent of Code to learn a new programming language. I used Rust in 2020, and Clojure in 2021.

This year I stayed with Clojure. I feel it’s a good fit for the Advent of Code. Clojure’s support for interactive development, the built-in data structures, and the core library functions allowed me to write clear, concise code that is almost exclusively about the problem at hand.

I wanted to write idiomatic, readable code. I don’t compete on the global leaderboard, I don’t care about coding speed, code size and performance.


This year I enjoyed all puzzles, even the hardest ones. The first two weeks went well and I followed a regular daily schedule: I solved the day’s problem before going to work, sometimes I coded a bit in the evening to polish my solution.

The difficulties started on Day 15. I didn’t pay attention to the problem description and I came up with an overly complicated, long, and buggy solution. Looking back, I should have stepped away from the problem for a day or two. Instead, I kept going and my performance in the next days suffered.

Exhausted from the previous day, I took another hit on Day 16 which was about opening valves to release pressure from a cave. I tried to formulate the solution as a shortest-path problem. My program solved correctly the given example but it ran out of memory when I gave it the real input. I also failed to solve the day as a search problem, as there were too many possibilities to explore. Finally, I looked at solutions online and an implementation using dynamic programming gave me a good solution.

Day 17 was about playing a variant of Tetris. The second part asked how many rows the board has after dropping a trillion rocks. Here I also used some help from others. The solution runs fast, but the implementation is clunky: I made it work but I was too tired to clean it up.

Day 19 was about building mining robots that can mine different resources. From the description, the problem looked similar to that of Day 16. Now I suspect that this similarity was a trap because an efficient solution ended up looking different. I borrowed the key idea from Johnathan Paulson: a depth-first search with a limit on the number of mining robots and the accumulated stock gave a correct and fast solution.

My favorite day was Day 22 which was about moving around on a map with “interesting” boundary conditions. I loved the plot twist in the second part which I don’t want to spoil. Many people gave up here, so I’m proud I made it. Later I’d like to generalize my solution because now it only works on the input generated for my account.


I had a great 2022 Advent of Code, this is my best year so far. My solutions are decent and they are my own except parts of Day 16, Day 17 and Day 19 where I used external help. Maybe next year I’ll recognize similar problems to solve all days on my own.

Solving the puzzles for 25 days next to my full-time job is exhausting. Perhaps for a few days, I pushed too hard and I should take more breaks next year.

As usual, after solving the puzzles I like to see how others approached the same problem. Here are some repositories I regularly checked:

My solutions are available on GitHub.


Thanks Eric Wastl for creating and running Advent of Code.

I enjoyed exchanging ideas and analyzing solutions with my friend Kornél.