|
12345678910111213141516171819202122232425262728 |
- import sys
-
- from intcode import compute
-
-
- tests = [
- ('3,0,4,0,99', [(12421, 12421)]),
- ('3,9,8,9,10,9,4,9,99,-1,8', [(8, 1), (7, 0)]),
- ('3,9,7,9,10,9,4,9,99,-1,8', [(7, 1), (8, 0), (9, 0)]),
- ('3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9', [(0, 0), (213, 1)]),
- ('3,3,1105,-1,9,1101,0,0,12,4,12,99,1', [(0, 0), (213, 1)]),
- ('''
- 3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,
- 1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,
- 999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99
- ''', [(7, 999), (8, 1000), (9, 1001)]),
- ]
-
-
- for program, pairs in tests:
- for inp, expect in pairs:
- out = list(compute(program, inp))[-1]
- assert out == expect, (out, expect)
-
-
- text = sys.stdin.read()
- print(list(compute(text, 1))[-1])
- print(list(compute(text, 5))[-1])
|