Discussion on: Advent of Code 2019 Solution Megathread - Day 15: Oxygen System

neilgall profile image
Neil Gall

Since it was Sunday I took the remote control metaphor to heart, added a server socket, modified my C IntCode machine so the socket performed the input and output, then went off to write the exploring code in another language to run in a separate process. I literally have to open two shells to run the solution.

Part 1 was an obvious depth-first search so I thought I'll do the search code in Haskell. Time was a bit broken up today but I got a bit bogged down in backtracking behaviour that wasn't quite tracking the correct position of the repair droid. Got there in the end however, and using depth-first meant the shortest route to the oxygen system fell out of the recorded path used for backtracking.

Part 2 is a classic "flood fill" algorithm. My space was encoded as a map of positions to contents, so an efficient implementation wasn't going to fall out naturally. Thankfully the space was small enough that it runs quickly:

$ time runhaskell day15.hs
Part 1 .. 296
Part 2 .. 302

real    0m3.919s
user    0m3.586s
sys 0m0.217s