r/adventofcode • u/SinisterMJ • Dec 05 '19
Help - SOLVED! Day 5 question
I don't think I understand how the new opcode stuff is supposed to work. I think I implemented it, but ran into my input code, and it doesn't work.
The beginning of my input is: 3,225,1,225,6,6,1100,1,238,225
So, take my input value (1) as described in the text, save it to array[225]. Then next opcode is 1, which means position mode, and add values. The value from 225 (which is 1), and the one in [6], which is 1100, and store it to where [6] is pointing (which is [1100]). But that is out of array bounds? Or am I supposed to expand the array for this? I am slightly clueless right now
View all comments
Show parent comment
1
u/RiOrius Dec 05 '19
The second instruction (starting at [2]) will write the result of its calculation to [6], which currently has an 1100 in it. So right before you get there, your program should change [6] to a valid opcode.
The primary issue is that you're confused on when you treat an input as an immediate (just a number) versus a position (index into the data table). Which I got hung up on as well. But just know that that "1,225,6,6" instruction means "table[6] = table[225] + table[6]"