-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday09_boost.py
36 lines (26 loc) · 1.15 KB
/
day09_boost.py
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
29
30
31
32
33
34
35
36
import pytest
from utils import IntCodeComputer
def test_process_copy_of_itself():
intcode_program = "109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99"
cpu = IntCodeComputer(intcode_program, memory_size=1024)
cpu.process()
assert str(cpu) == intcode_program
def test_output_has_16_chars():
intcode_program = "1102,34915192,34915192,7,4,7,99,0"
cpu = IntCodeComputer(intcode_program, memory_size=1024)
cpu.process()
assert len(str(cpu.captured_output[0])) == 16
def test_output_produces_middle_number():
intcode_program = "104,1125899906842624,99"
cpu = IntCodeComputer(intcode_program, memory_size=1024)
cpu.process()
assert cpu.captured_output[0] == 1125899906842624
if __name__ == "__main__":
with open("2019/data/day09_input.txt", "r") as f:
intcode_program = f.readline().strip()
cpu = IntCodeComputer(intcode_program, memory_size=1_000_000, input_value=1)
cpu.process()
print(f"Test program output: {cpu.captured_output[0]}")
cpu = IntCodeComputer(intcode_program, memory_size=1_000_000, input_value=2)
cpu.process()
print(f"Boost program output: {cpu.captured_output[0]}")