You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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