X = the sum of the alignment parameters for the scaffold intersections
X = the amount of dust reported as collected after the robot visits every part of the scaffold at least once
Instead, example output is given:
- ASCII codes
- Scaffolding as
- Emptiness as
- Displayed in lines, separated by
- Turning ASCII codes into characters
- Testing the program's first few output codes using a new Intcode computer
- Seeing the whole picture
- Using the whole picture to generate the correct answer
I had to look this up.
String.fromCharCode(35) // '#' String.fromCharCode(46) // '.' String.fromCharCode(10) // '\n'
- I already configured my last Intcode computer simulator to run until a new value is added to output
- I just have to update it such that it renders another character in a string...instead of a newly discovered wall, empty space or oxygen location
One new simulator...coming right up!
I've solved puzzles like this a few times before algorithmically.
This time, I wanted to do it visually.
- Visualizing the path to calculate and determine the ASCII codes for each movement function
- Attempting to feed each code as input to the Intcode program
- Troubleshooting, fully annotated
- Proof that I succeeded in moving the robot
- Could I update my simulator to render the continuous feed?
This presented another required use of my design tool to draw the map.
- I'm under the impression that I need to feed each ASCII code, one after the other, as soon as a new value is output via
- I foresee it not being quite that easy, but hopefully I'm either correct or close enough that I can troubleshoot and ultimately generate the single large non-ASCII value
Time to update my Intcode computer and program, run it, and see what I get!
- I initially set up my instructions as a flat list of character codes representing my movement commands and functions
- After debugging my computer enough to see some initial output, I realized it expected separated lists
- This meant I had to convert my flat list into a nested array
- And update my code to track two locations: 1) which list to reference, 2) which index to reference
After fiddling with code until I was seeing the correct list and locations print, I turned my attention to the
X shown in the image above, representing a misplaced robot.
Somehow, my converted instructions must be wrong, because the robot should not be falling off!
I mistakenly thought
10 was one number!
'10'.charCodeAt() // 49
charCodeAtdefaults to position 0, which is
Therefore, what I thought in my instructions was:
Was actually being converted to:
I needed to insert the character code for 0 (
48) - and 2 (
50), elsewhere that the instruction was 12 - at the appropriate locations in my nested arrays where I already had a
Refresh page. Press button to run code.
- The final rendered state of the grid shows a robot in the ending scaffold location
- The symbol at the bottom is proof that the last value in my output is something other than a 1- or 2-digit number
Indeed, it was the expected large integer mentioned in the puzzle instructions.
- Right now, the page prints all states of the scene, one below the other
- I really want each scene to replace the prior state of the scene in millisecond increments
It took some wonky magic number math and trial and error.
But I got my simulator to render the continuous video feed as a new set of ASCII characters on the page.
- I solved both parts!
- I made a few GIFs to visualize my manual puzzle-solving algorithms!
- I made another simulator that renders each step taken by the controlled robot!
- I've now solved 8/8 Intcode computer puzzles!
- I've now built 8 Intcode computer simulators!