Esempio n. 1
0
 def test_day9_part1(self):
     datas = [
         (
             "109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99",
             [
                 109,
                 1,
                 204,
                 -1,
                 1001,
                 100,
                 1,
                 100,
                 1008,
                 100,
                 16,
                 101,
                 1006,
                 101,
                 0,
                 99,
             ],
         ),
         ("1102,34915192,34915192,7,4,7,99,0", [1219070632396864]),
         ("104,1125899906842624,99", [1125899906842624]),
     ]
     for data, result in datas:
         with self.subTest(data=data):
             p = Program(data)
             p.execute()
             self.assertEqual(list(p), result)
Esempio n. 2
0
 def test_day2_part1(self):
     datas = [
         ("1,9,10,3,2,3,11,0,99,30,40,50", 3500),
     ]
     for data, result in datas:
         with self.subTest(data=data):
             p = Program(data)
             p.execute()
             self.assertEqual(p._Program__memory[0], result)
Esempio n. 3
0
 def test_day5_part2(self):
     datas = [
         (
             "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99",
             7,
             999,
         ),
         (
             "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99",
             8,
             1000,
         ),
         (
             "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99",
             9,
             1001,
         ),
     ]
     for data, data_input, result in datas:
         with self.subTest(data=data):
             p = Program(data)
             p.send_input(data_input)
             p.execute()
             self.assertEqual(next(p), result)
Esempio n. 4
0
def main():
    data = sys.stdin.readline()
    p = Program(data)
    p.send_input(1)
    p.execute()
    print(list(p))