Advent of Code 2019 Day 15
Try the simulator using your puzzle input!
Task: Solve for X where...
X = the fewest number of movement commands required to move the repair droid from its starting position to the location of the oxygen system
X = the number of minutes it will take to fill the space with oxygen
No example input
- Instead, several example input instructions and resulting output commands are simulated
- Intcode computer: Round 7!
- Forget the algorithm: straight to building a simulator
- The simulator revealed the path!
- I painstakingly counted, and got the correct answer
Intcode computer: Round 7!
- Similar to Round 5 (Day 11), I must move a robot
- Unlike Round 5, the robot's path depends on my instructions, not just the state of the ground upon which it stands
Only four movement commands are understood: north (1), south (2), west (3), and east (4)
- A single output: one of
0: Wall. Didn't move.
1: Open. Moved.
2: Moved. At oxygen system!
Direct the repair droid to the oxygen system and fix the problem
Forget the algorithm: straight to building a simulator
- I have no idea how I would algorithmically solve this puzzle
- But I do know how to build a simulator where I can listen for the next direction, run the program until it outputs another value, and update the robot's position and state of the area based on the status code
Off I go to try. Be back soon!
Ok, I'm back!
The simulator revealed the path!
- I built the simulator assuming a 50x50 square area, with the droid starting in the middle
- Just like in the instructions, I replace the contents of a cell with the correct object based on the status code returned after each attempted move
- I mapped each keyboard arrow key to the four input directions to make it delightfully interactive
Here's an animation of how the simulator revealed the path
I painstakingly counted, and got the correct answer
After some back-tracking to identify all the walls, I had what I needed to count the minimum steps necessary:
Here's a closer look at the shortest path:
- Forget the algorithm: I'll make a GIF!
- To my delight, it was the correct answer!
Forget the algorithm: I'll make a GIF!
- 313 frames
- Each crafted individually
- Using letters from the alphabet to keep myself on track
It runs in about as many seconds as the hours it took to create:
To my delight, it was the correct answer!
- I'm so glad I used the alphabet and named my frames to match the number of minutes I was on
I did it!!!
- I solved both parts!
- I created my most complex GIF thus far in the series...and thankfully got the correct answer out of the tedious exercise!
- I built an interactive robot-maze-traversing simulator that helped me reveal the full maze, including the location of the oxygen system
- I've now completed 7/7 Intcode puzzles
- I've now built 7 Intcode computer simulators
The goal is always to solve, not necessarily with an algorithm.
And in my opinion, building a game is always a great way to solve these puzzles!
Top comments (0)