-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.py
More file actions
33 lines (26 loc) · 707 Bytes
/
solution.py
File metadata and controls
33 lines (26 loc) · 707 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
29
30
31
32
33
import os
import sys
sys.path.insert(
0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../intcode'))
)
from intcode import IntcodeComputer
def main():
program = list(map(int, sys.stdin.readline().strip().split(',')))
output = []
computer = IntcodeComputer(
program=program,
input_callback=lambda: 1,
output_callback=lambda value: output.append(value),
)
computer.run()
print(output[0])
output = []
computer = IntcodeComputer(
program=program,
input_callback=lambda: 2,
output_callback=lambda value: output.append(value),
)
computer.run()
print(output[0])
if __name__ == '__main__':
main()