An Intcode program is a list of integers separated by commas (like 1,0,0,3,99). To run one, start by looking at the first integer (called position 0). Here, you will find an opcode - either 1, 2, or 99. The opcode indicates what to do; for example, 99 means that the program is finished and should immediately halt. Encountering an unknown opcode means something went wrong.
Opcode 1 adds together numbers read from two positions and stores the result in a third position. The three integers immediately after the opcode tell you these three positions - the first two indicate the positions from which you should read the input values, and the third indicates the position at which the output should be stored.
For example, if your Intcode computer encounters 1,10,20,30, it should read the values at positions 10 and 20, add those values, and then overwrite the value at position 30 with their sum.
Opcode 2 works exactly like opcode 1, except it multiplies the two inputs instead of adding them. Again, the three integers after the opcode indicate where the inputs and outputs are, not their values.
Once you're done processing an opcode, move to the next one by stepping forward 4 positions.
For example, suppose you have the following program:
For the purposes of illustration, here is the same program split into multiple lines:1,9,10,3,2,3,11,0,99,30,40,50
The first four integers, 1,9,10,3, are at positions 0, 1, 2, and 3. Together, they represent the first opcode (1, addition), the positions of the two inputs (9 and 10), and the position of the output (3). To handle this opcode, you first need to get the values at the input positions: position 9 contains 30, and position 10 contains 40. Add these numbers together to get 70. Then, store this value at the output position; here, the output position (3) is at position 3, so it overwrites itself. Afterward, the program looks like this:1,9,10,3, 2,3,11,0, 99, 30,40,50
Step forward 4 positions to reach the next opcode, 2. This opcode works just like the previous, but it multiplies instead of adding. The inputs are at positions 3 and 11; these positions contain 70 and 50 respectively. Multiplying these produces 3500; this is stored at position 0:1,9,10,70, 2,3,11,0, 99, 30,40,50
Stepping forward 4 more positions arrives at opcode 99, halting the program. Here are the initial and final states of a few more small programs:3500,9,10,70, 2,3,11,0, 99, 30,40,50
1,0,0,0,99 becomes 2,0,0,0,99 (1 + 1 = 2). 2,3,0,3,99 becomes 2,3,0,6,99 (3 * 2 = 6). 2,4,4,5,99,0 becomes 2,4,4,5,99,9801 (99 * 99 = 9801). 1,1,1,4,99,5,6,0,99 becomes 30,1,1,4,2,5,6,0,99.
VP 60.1: 1202 Program Alarm (15 pts)
Use this data:https://samsclass.info/COMSC122/proj/VP60We're debugging that program. It crashed at a "1202 Alarm" state.To reproduce the situation at the crash, before running the program, replace position 1 with the value 12 and replace position 2 with the value 2.
What value is left at position 0 after the program halts? That number is the flag.
For the previous flag, the Noun was 12 and the Verb was 2.
Try all possible Noun and Verb values from 0 through 99, for a total of 10,000 possible combinations.
Find the Noun and Verb that result in this value at position 0: 19690720
Each time you try a pair of inputs, make sure you first reset the computer's memory to the values in the program (your puzzle input) - in other words, don't reuse memory from a previous attempt.
VP 60.2: Noun and Verb (15 pts)
Your input is this data, the same as before:https://samsclass.info/COMSC122/proj/VP60Find the input noun and verb that cause the program to produce the output 19690720. What is 100 * noun + verb? (For example, if noun=12 and verb=2, the answer would be 1202.)That number is the flag.
Posted 11-15-25
Minor update 11-16-25