Advent of Code 2022 notes

Haskell | Problem statements | Source code

2022 was my second year doing AoC. I was freshly in college and had time to spare. In early 2022, out of boredom after college application, and inspired by everyone raving about functional programming™, I decided to learn Haskell via Wikibooks. AoC was a great way to try it out, especially since algorithm problems would involve far less fiddling with monads compared to IRL projects. I was very thankful for this experience: two years later, I took a software analysis and verification class where half of my projects were written in Haskell, and I was immediately at home.

Anyway, in 2022, I soon found out that I was inflicting pain on myself because I often have to wrap my head around doing things with tail recursion. BFS was intuitive to read but not at all intuitive to write, at least when I was new. There were a lot of folds, a lot of states being passed around, and a lot of inconsistency in my code style (despite using HLint). For example, 7 would have been a trivial problem in mutable languages but was a bit verbose and error-prone in Haskell. Nevertheless, I would rate 2022 very high on my "enjoyment" scale because the code was always extremely neat and concise—features I highly value. Towards the latter half, I became very familiar with the language and it stopped being a hindrance.

Difficulty-wise, I consider this year a significant hike from 2021. I bailed on 15, when I couldn't see clearly how to model it mathematically. Even in hindsight, 15 was a particularly hard problem especially at this numbering. 16 and 19 were very challenging among DP problems, especially because the pruning strategies for 19 were not obvious. 18 was not supposed to be a pain; half of the difficulty, IMO, came from using Haskell. 20 is brute-forceable but was significantly sped up with an order statistic tree, which the 2022 me couldn't have known existed. On the upside though, 21–25 were all very approachable, although I was already intimidated and didn't come back (also I was traveling around).

landing page