105, 1, 0, 1105, 1, 99999, 1106, 0, 300, 1105, 1, 99999, 1, 225, 225, 225, 1101, 314, 0, 0, 106, 0, 0, 1105, 1, 99999, 107, 226, 226, 224, 1002, 223, 2, 223, 1005, 224, 329, 1001, 223, 1, 223, 1007, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 344, 101, 1, 223, 223, 1008, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 359, 1001, 223, 1, 223, 8, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 374, 101, 1, 223, 223, 1107, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 389, 101, 1, 223, 223, 1108, 226, 677, 224, 102, 2, 223, 223, 1005, 224, 404, 101, 1, 223, 223, 107, 677, 677, 224, 102, 2, 223, 223, 1006, 224, 419, 1001, 223, 1, 223, 7, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 434, 101, 1, 223, 223, 1007, 677, 677, 224, 102, 2, 223, 223, 1005, 224, 449, 1001, 223, 1, 223, 108, 226, 677, 224, 102, 2, 223, 223, 1005, 224, 464, 1001, 223, 1, 223, 108, 226, 226, 224, 102, 2, 223, 223, 1006, 224, 479, 101, 1, 223, 223, 107, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 494, 1001, 223, 1, 223, 7, 226, 226, 224, 1002, 223, 2, 223, 1006, 224, 509, 101, 1, 223, 223, 1108, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 524, 101, 1, 223, 223, 1107, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 539, 101, 1, 223, 223, 1008, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 554, 101, 1, 223, 223, 1008, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 569, 101, 1, 223, 223, 1107, 677, 677, 224, 102, 2, 223, 223, 1006, 224, 584, 1001, 223, 1, 223, 1108, 226, 226, 224, 1002, 223, 2, 223, 1006, 224, 599, 101, 1, 223, 223, 7, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 614, 101, 1, 223, 223, 108, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 629, 101, 1, 223, 223, 1007, 677, 226, 224, 102, 2, 223, 223, 1006, 224, 644, 101, 1, 223, 223, 8, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 659, 101, 1, 223, 223, 8, 677, 226, 224, 102, 2, 223, 223, 1005, 224, 674, 101, 1, 223, 223, 4, 223, 99, 226 ] if __name__ == "__main__": intcode_computer.calculate(stack)
def test_opcode_8_immediate_equal(self, print_): stack = [3, 3, 1108, -1, 8, 3, 4, 3, 99] intcode_computer.input = lambda _: 8 intcode_computer.calculate(stack) print_.assert_called_with(1)
def test_opcode_7_immediate_greater(self, print_): stack = [3, 3, 1107, -1, 8, 3, 4, 3, 99] intcode_computer.input = lambda _: 9 intcode_computer.calculate(stack) print_.assert_called_with(0)
def test_opcode_1(self): stack = list([1, 3, 3, 3]) intcode_computer.calculate(stack) self.assertEqual(stack[3], 6, 'Adding failed')
def test_opcode_7_greater_than(self, print_): stack = [3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8] intcode_computer.input = lambda _: 9 intcode_computer.calculate(stack) print_.assert_called_with(0)
def test_opcode_4(self, print_): stack = list([4, 2, 99]) intcode_computer.calculate(stack) print_.assert_called_with(99)
def test_opcode_8_not_equals(self, print_): stack = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8] intcode_computer.input = lambda _: 7 intcode_computer.calculate(stack) print_.assert_called_with(0)
def test_opcode_3(self): stack = list([3, 0, 99]) intcode_computer.input = lambda _: 1 intcode_computer.calculate(stack) self.assertEqual(1, stack[0])
def test_opcode_2(self): stack = list([2, 5, 6, 4, 0, 33, 3]) intcode_computer.calculate(stack) self.assertEqual(stack[4], 99, 'Multiplying')
def test_opcode_jumps_immediate_not_equal(self, print_): stack = [3, 3, 1105, -1, 9, 1101, 0, 0, 12, 4, 12, 99, 1] intcode_computer.input = lambda _: 6 intcode_computer.calculate(stack) print_.assert_called_with(1)
def test_opcode_jumps_not_equal(self, print_): stack = [3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9] intcode_computer.input = lambda _: 6 intcode_computer.calculate(stack) print_.assert_called_with(1)
def test_opcode_1_correct_position(self): stack = list([1, 5, 6, 7, 99, 4, 3, 0]) intcode_computer.calculate(stack) self.assertEqual(stack[7], 7, 'Correct place')