Esempio n. 1
0
 def test_processMedStruct(self):
     struct = [
         28, 33, 18, 42, 31, 14, 46, 20, 48, 47, 24, 23, 49, 45, 19, 38, 39,
         11, 1, 32, 25, 35, 8, 17, 7, 9, 4, 2, 34, 10, 3
     ]
     paths = processStruct(struct)
     self.assertEqual(paths, 19208)
Esempio n. 2
0
 def test_processShortStruct(self):
     struct = [
         35, 20, 15, 25, 47, 40, 62, 55, 65, 95, 102, 117, 150, 182, 127,
         219, 299, 277, 309, 576
     ]
     target = 127
     self.assertEqual(62, processStruct(struct, target))
Esempio n. 3
0
 def test_program_03(self):
     struct = [("nop", +0), ("acc", +1), ("jmp", +4), ("acc", +3),
               ("jmp", -3), ("acc", -99), ("acc", +1), ("jmp", -4),
               ("acc", +6)]
     changeOperation(struct, 7)
     self.assertEqual(struct[7][0], "nop")
     self.assertTrue(processStruct(struct))
Esempio n. 4
0
    def test_processShortStruct(self):
        struct = [
            35, 20, 15, 25, 47, 40, 62, 55, 65, 95, 102, 117, 150, 182, 127,
            219, 299, 277, 309, 576
        ]
        preamble = 5
        stopAt = len(struct)
        subset = getRange(5, stopAt)
        # we want to process all the positions from 40 (first number with 5 before) up to 576
        self.assertEqual(struct[subset[0]], 40)
        self.assertEqual(struct[subset[-1]], 576)

        self.assertEqual(getNPreviousNumbers(struct, subset[0], preamble),
                         [35, 20, 15, 25, 47])

        self.assertEqual(127, processStruct(struct, preamble))
Esempio n. 5
0
 def test_processShortStruct(self):
     struct = [16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4]
     paths = processStruct(struct)
     self.assertEqual(paths, 8)
Esempio n. 6
0
 def test_5(self):
     struct = []
     struct = processLineOfInputIntoStruct("1789,37,47,1889")
     self.assertEqual(1202161486,processStruct(struct))
Esempio n. 7
0
 def test_4(self):
     struct = []
     struct = processLineOfInputIntoStruct("67,7,x,59,61")
     self.assertEqual(1261476,processStruct(struct))
Esempio n. 8
0
 def test_3(self):
     struct = []
     struct = processLineOfInputIntoStruct("67,x,7,59,61")
     self.assertEqual(779210,processStruct(struct))
Esempio n. 9
0
 def test_2(self):
     struct = []
     struct = processLineOfInputIntoStruct("67,7,59,61")
     self.assertEqual(754018,processStruct(struct))
Esempio n. 10
0
 def test_1(self):
     struct = []
     struct = processLineOfInputIntoStruct("17,x,13,19")
     self.assertEqual(struct,[(0, 17), (2, 13), (3,19)])
     self.assertEqual(3417,processStruct(struct))
Esempio n. 11
0
 def test_0(self):
     struct = []
     struct = processLineOfInputIntoStruct("7,13,x,x,59,x,31,19")
     self.assertEqual(struct,[(0, 7), (1, 13),(4, 59), (6,31),(7,19)])
     self.assertEqual(1068781,processStruct(struct))
Esempio n. 12
0
 def test_processMedStruct(self):
     struct = [28,33,18,42,31,14,46,20,48,47,24,23,49,45,19,38,39,11,1,32,25,35,8,17,7,9,4,2,34,10,3]
     dist = processStruct(struct)
     self.assertEqual( dist[1],22)
     self.assertEqual( dist[3],10)
Esempio n. 13
0
 def test_processShortStruct(self):
     struct = [16,10,15,5,1,11,7,19,6,12,4]
     dist = processStruct(struct)
     self.assertEqual( dist[1],7)
     self.assertEqual( dist[3],5)
Esempio n. 14
0
 def test_testInputFile2(self):
     struct = processInputFile(
         os.path.join(os.path.dirname(__file__), "test_input_2.txt"))
     self.assertEqual(len(struct), 4)
     self.assertEqual(165, processStruct(struct))
Esempio n. 15
0
 def test_program_01(self):
     struct = [("nop", +0), ("acc", +1), ("jmp", +4), ("acc", +3),
               ("jmp", -3), ("acc", -99), ("acc", +1), ("jmp", -4),
               ("acc", +6)]
     processStruct(struct)