Beispiel #1
0
 def test_cmd02_position(self):
     code = Intcode([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10)
     code.pointer = 4
     operation = f'{code.program[code.pointer]:>05}'
     code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3]))
     code.cmd02()
     assert code.program == [150, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]
     assert code.pointer == 8
     assert not code.terminated
Beispiel #2
0
 def test_cmd02_immediate3(self):
     code = Intcode([1, 9, 10, 12, 1102, 3, 11, 0, 99, 30, 40, 50], 9, 10)
     code.pointer = 4
     operation = f'{code.program[code.pointer]:>05}'
     code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3]))
     code.cmd02()
     assert code.parm1
     assert code.parm2
     assert not code.parm3
     assert code.program == [33, 9, 10, 12, 1102, 3, 11, 0, 99, 30, 40, 50]
     assert code.pointer == 8
     assert not code.terminated
Beispiel #3
0
 def test_cmd02_immediate1(self):
     code = Intcode([1, 9, 10, 3, 102, 5, 11, 0, 99, 30, 40, 50], 9, 10)
     code.pointer = 4
     operation = f'{code.program[code.pointer]:>05}'
     code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3]))
     code.cmd02()
     assert code.parm1
     assert not code.parm2
     assert not code.parm3
     assert code.program == defaultdict(
         int, enumerate([250, 9, 10, 3, 102, 5, 11, 0, 99, 30, 40, 50]))
     assert code.pointer == 8
     assert not code.terminated