diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:18:18 -0400 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:19:39 -0400 |
| commit | 87ab487d59fa85dbe2afa55cc841b02805ae42ca (patch) | |
| tree | cd90ab715e1b5b5803674045dbafd6d51d27ac90 /src/02/part2 | |
| parent | 1bcc82c5bfbde87edd03c01ffdf9ee5934681592 (diff) | |
| download | aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.tar.gz aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.zip | |
Reorder days into src
Diffstat (limited to 'src/02/part2')
| -rw-r--r-- | src/02/part2 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/02/part2 b/src/02/part2 new file mode 100644 index 0000000..cf1b625 --- /dev/null +++ b/src/02/part2 @@ -0,0 +1,41 @@ +--- Part Two --- + +"Good, the new computer seems to be working correctly! [1m[97mKeep it nearby[0m during this mission - you'll +probably use it again. Real Intcode computers support many more features than your new one, but +we'll let you know what they are as you need them." + +"However, your current priority should be to complete your gravity assist around the Moon. For this +mission to succeed, we should settle on some terminology for the parts you've already built." + +Intcode programs are given as a list of integers; these values are used as the initial state for the +computer's [1m[97mmemory[0m. When you run an Intcode program, make sure to start by initializing memory to the +program's values. A position in memory is called an [1m[97maddress[0m (for example, the first value in memory +is at "address 0"). + +Opcodes (like 1, 2, or 99) mark the beginning of an [1m[97minstruction[0m. The values used immediately after +an opcode, if any, are called the instruction's [1m[97mparameters[0m. For example, in the instruction +1,2,3,4, 1 is the opcode; 2, 3, and 4 are the parameters. The instruction 99 contains only an opcode +and has no parameters. + +The address of the current instruction is called the [1m[97minstruction pointer[0m; it starts at 0. After an +instruction finishes, the instruction pointer increases by [1m[97mthe number of values in the +instruction[0m; until you add more instructions to the computer, this is always 4 (1 opcode + 3 +parameters) for the add and multiply instructions. (The halt instruction would increase the +instruction pointer by 1, but it halts the program instead.) + +"With terminology out of the way, we're ready to proceed. To complete the gravity assist, you need +to [1m[97mdetermine what pair of inputs produces the output 19690720[0m." + +The inputs should still be provided to the program by replacing the values at addresses 1 and 2, +just like before. In this program, the value placed in address 1 is called the [1m[97mnoun[0m, and the value +placed in address 2 is called the [1m[97mverb[0m. Each of the two input values will be between 0 and 99, +inclusive. + +Once the program has halted, its output is available at address 0, also just like before. Each time +you try a pair of inputs, make sure you first [1m[97mreset the computer's memory to the values in the +program[0m (your puzzle input) - in other words, don't reuse memory from a previous attempt. + +Find the input [1m[97mnoun[0m and [1m[97mverb[0m that cause the program to produce the output 19690720. [1m[97mWhat is 100 * +noun + verb?[0m (For example, if noun=12 and verb=2, the answer would be 1202.) + + |
