Пример #1
0
 def test_provided(self):
     self.assertEqual(
         3500, run_program([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50]))
     self.assertEqual(2, run_program([1, 0, 0, 0, 99]))
     self.assertEqual(2, run_program([2, 3, 0, 3, 99]))
     self.assertEqual(2, run_program([2, 4, 4, 5, 99, 0]))
     self.assertEqual(30, run_program([1, 1, 1, 4, 99, 5, 6, 0, 99]))
Пример #2
0
    def test_run_program(self):
        # Test case 1 should produce a copy of itself as output
        sequence = [109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99]
        result = part1.run_program(sequence, input_value=None)
        #self.assertListEqual(result, sequence)

        # Test case 2 should output a 16-digit number
        sequence = [1102,34915192,34915192,7,4,7,99,0]
        result = part1.run_program(sequence, input_value=None)
        self.assertEqual(len(str(result)), 16)

        # Test case 3 should output the large number in the middle (1125899906842624)
        sequence = [104,1125899906842624,99]
        result = part1.run_program(sequence, input_value=None)
        self.assertEqual(result, 1125899906842624)
Пример #3
0
 def test_1(self):
     string_program = "1102,34915192,34915192,7,4,7,99,0"
     assert run_program(string_program, []) == [1219070632396864]
Пример #4
0
 def test_3(self):
     string_program = "109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99"
     assert run_program(string_program, []) == [
         109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99
     ]
Пример #5
0
 def test_2(self):
     string_program = "104,1125899906842624,99"
     assert run_program(string_program, []) == [1125899906842624]