-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday2.py
More file actions
28 lines (20 loc) · 709 Bytes
/
Copy pathday2.py
File metadata and controls
28 lines (20 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import utils
from intcode_computer import IntcodeComputer
program = [int(x) for x in utils.read_lines(2)[0].split(",")]
computer = IntcodeComputer()
computer.load_program_from_int_array(program)
# Init to "1202 program alarm" state
computer.set_address(1, 12)
computer.set_address(2, 2)
computer.execute()
print(computer.get_address(0))
computer = IntcodeComputer()
for noun, verb in ((i, j) for i in range(0,100) for j in range(0,100)):
print(f"Processing ({noun},{verb})")
computer.load_program_from_int_array(program)
computer.set_address(1, noun)
computer.set_address(2, verb)
computer.execute()
if computer.get_address(0) == 19690720:
print(f"{noun}, {verb} - {100*noun + verb}")
break