advent of code - day 9
2023-12-09
See the puzzle here.
See my full solution here.
Both parts were nearly the same code. I'm not sure if there was a trick I didn't fall for, but I knocked this one out pretty quick and barely had to modify the code between both parts.
Here's the main chunk of code from my solution:
let allDone = false;
let index = 0;
// Build the patterns
while(!allDone) {
allDone = true;
for(let i=0; i
Basically, while all of the values in the latest difference array aren't 0, keep looping until they all are. Then use the differences to go back and fill in the last values.
The second part is basically the same, except using the differences to go back and fill in the preceding values.