AoC 2019 D15: Oxygen System
| Problem statement | Source code | Tags: IntcodeBFS/DFSMaze
← Previous Back to AoC Index Next →
This problem really shows what Intcode has to offer, and is what I'd say the first problem that's not just "run this Intcode program". This kind of problem is impossible to create with an Intcode VM, since it's basically a CTF-style interactive puzzle.
Part 1
Originally, I listened to Reddit wisdom to just explore the maze with rand(), but I found that the droid often just oscillates in a small region. In the end I still went for an actual DFS. I keep track of the directions I've taken; every time, I pick an unexplored direction if possible; otherwise, I backtrack by reverting the last move.
For part 1, I could have stopped when I found the oxygen system, but since part 2 requires the full map, I just explored the entire map. After we do this, it's just a normal AoC-style maze BFS problem.
Part 2
Part 1 already built the full map, so part 2 is just a BFS from the oxygen system to find the maximum distance to any reachable cell.