Advent of Code

Advent of Code 2020, Day 5

Curiously, day 5 was actually simpler than day 4. My solution is over on my git repo, and as always, this post contains spoilers for day 5 and earlier.

First of all, I’m continuing to love the writing introducing the problems. Let me just quote the first paragraph verbatim:

You board your plane only to discover a new problem: you dropped your boarding pass! You aren’t sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control.

This is just brilliant, I think. Yep, the current issue is the obvious solution to the avoidable problem is unavailable because of the solution to the last avoidable problem. Our protagonist is actually a lot like me: forgetful, accident-prone, and tends towards the most complicated possible solution to a given problem. It’s like Eric Wastl knows his audience.

The puzzle itself wasn’t actually anything special, its introduction and framing aside. It’s a simple binary space partition, which is once again the sort of problem Haskell excels at. Read the encoded instructions character by character, and move the upper or lower bound of the search space depending on which character it is until you get one answer. Trivially easy with a recursive function.

Part 2 didn’t add much. Find the seat number that’s missing from the list. My solution to that was just to sort the list (it’s only got 800 elements or so) and look for two elements that aren’t numerically adjacent. Since I figured out how to deal with comparing two adjacent list elements yesterday, also pretty easy.

My seat’s in row 69, column 5, by the way. Come over and say hi if you’re on the flight once the seat belt lights go off.

Both parts of this puzzle are complete! They provide two gold stars: **

I’m a little disappointed that there hasn’t been some sort of ongoing thread like there was with 2019’s Intcode interpreter. Throughout the month, you were slowly building up a more and more capable interpreter for some made-up machine code, each day’s solution building on the last one. There hasn’t been anything like that here so far, and the fact that we’ve got to day 5 without seeing any sign of one isn’t promising.

I’m also starting to feel like using Haskell for Advent of Code might be cheating a bit. It seems perfectly geared towards exactly the sorts of puzzles that have been coming up… though just watch when day 19 comes along, the really hard puzzles kick in, and I have to eat those words.