def test_cmd2(self): code = Intcode([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) code.pointer = 4 code.cmd2() assert code.program == [150, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 4 assert not code.terminated
def test_cmd99(self): code = Intcode([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) code.pointer = 8 code.cmd99() assert code.program == [1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 8 assert code.terminated
def test_cmd99(self): code = Intcode([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) code.pointer = 8 code.cmd99() assert code.program == defaultdict( int, enumerate([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50])) assert code.pointer == 8 assert code.terminated
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
def test_cmd08_equals_false(self): code = Intcode([7, 10, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]) code.pointer = 0 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd08() assert code.program == [7, 10, 10, 1, 2, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 4 assert not code.terminated
def test_cmd06_position_jump_if_false_false(self): code = Intcode([6, 7, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]) code.pointer = 0 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd06() assert code.program == [6, 7, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 40 assert not code.terminated
def test_cmd07_less_than_false(self): code = Intcode([7, 10, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]) code.pointer = 0 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd07() assert code.program == defaultdict( int, enumerate([7, 10, 10, 0, 2, 3, 11, 0, 99, 30, 40, 50])) assert code.pointer == 4 assert not code.terminated
def test_cmd05_position_jump_if_true_false(self): code = Intcode([5, 7, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]) code.pointer = 0 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd05() assert code.program == defaultdict( int, enumerate([5, 7, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50])) assert code.pointer == 3 assert not code.terminated
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
def test_cmd03(self): code = Intcode([3, 2, 10, 12, 1102, 3, 11, 0, 99, 30, 40, 50], inp=5) code.pointer = 0 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd03() assert code.inp == 5 assert not code.parm1 assert not code.parm2 assert not code.parm3 assert code.program == [3, 2, 5, 12, 1102, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 2 assert not code.terminated
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