def test_Task2_2(self): solver = AoC() solver.data = [ 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 ] result = solver.Task2() self.assertEqual(19208, result)
def test_Task2(self): solver = AoC() solver.data = ["mask = 000000000000000000000000000000X1001X", "mem[42] = 100", "mask = 00000000000000000000000000000000X0XX", "mem[26] = 1"] result = solver.Task2() self.assertEqual(208, result)
def test_Task1(self): solver = AoC() solver.data = ["mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X", "mem[8] = 11", "mem[7] = 101", "mem[8] = 0"] result = solver.Task1() self.assertEqual(165, result)
def test_Task1(self): solver = AoC() solver.preambleLength = 5 solver.data = [ 35, 20, 15, 25, 47, 40, 62, 55, 65, 95, 102, 117, 150, 182, 127, 219, 299, 277, 309, 576 ] fault = solver.Task1() self.assertEqual(127, fault)
def test_two_movement_steps(self): solver = AoC() solver.data = [ "L.LL.LL.LL", "LLLLLLL.LL", "L.L.L..L..", "LLLL.LL.LL", "L.LL.LL.LL", "L.LLLLL.LL", "..L.L.....", "LLLLLLLLLL", "L.LLLLLL.L", "L.LLLLL.LL" ] _map = solver.generateMap(solver.data) solver.simulateMovements(_map) self.assertEqual(71, solver.countOccupiedSeats(_map)) solver.simulateMovements(_map) self.assertEqual(20, solver.countOccupiedSeats(_map))
def test_Task1(self): solver = AoC() solver.data = [ "L.LL.LL.LL", "LLLLLLL.LL", "L.L.L..L..", "LLLL.LL.LL", "L.LL.LL.LL", "L.LLLLL.LL", "..L.L.....", "LLLLLLLLLL", "L.LLLLLL.L", "L.LLLLL.LL" ] solver.data = solver.generateMap(solver.data) self.assertEqual(37, solver.Task1())
def test_TicketGenerator(self): solver = AoC() solver.data = ["nearby tickets:\n7,3,47\n40,4,50\n55,2,20\n38,6,12"] solver.generateData() self.assertEqual(4, len(solver.nearbyTickets))
def test_generateDataset(self): solver = AoC() input_data = ["939", "7,13,x,x,59,x,31,19"] solver.generateDataset(input_data) self.assertEqual(939, solver.timestamp) self.assertEqual(8, len(solver.busses))
def test_Task2_6(self): solver = AoC() input_data = ["939", "1789,37,47,1889"] solver.generateDataset(input_data) result = solver.Task2(offset=1202161400) self.assertEqual(1202161486, result)
def test_Task2_5(self): solver = AoC() input_data = ["939", "67,7,x,59,61"] solver.generateDataset(input_data) result = solver.Task2() self.assertEqual(1261476, result)
def test_solvesolveEquationAdditionPrecedent_with_high_complexity(self): solver = AoC() result = solver.solveEquationAdditionPrecedent("((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2") self.assertEqual(23340, result)
def test_Task1(self): solver = AoC() solver.data = [0, 3, 6] result = solver.Task1(2020) self.assertEqual(436, result) solver.data = [1, 3, 2] result = solver.Task1(2020) self.assertEqual(1, result) solver.data = [2, 1, 3] result = solver.Task1(2020) self.assertEqual(10, result) solver.data = [1, 2, 3] result = solver.Task1(2020) self.assertEqual(27, result) solver.data = [2, 3, 1] result = solver.Task1(2020) self.assertEqual(78, result) solver.data = [3, 2, 1] result = solver.Task1(2020) self.assertEqual(438, result) solver.data = [3, 1, 2] result = solver.Task1(2020) self.assertEqual(1836, result)
def test_Task2_6(self): solver = AoC() solver.data = [3, 2, 1] result = solver.Task2() self.assertEqual(18, result)
def test_Task2(self): solver = AoC() solver.data = [0, 3, 6] result = solver.Task2() self.assertEqual(175594, result)
def test_Task2_3(self): solver = AoC() solver.data = [2, 1, 3] result = solver.Task2() self.assertEqual(3544142, result)
def test_Task2(self): solver = AoC()
def test_Task1(self): solver = AoC() solver.data = [".#.", "..#", "###"] solver.generateData() result = solver.Task1(6) self.assertEqual(112, result)
def test_Datagenerator(self): solver = AoC() solver.data = [".#.", "..#", "###"] solver.generateData() self.assertEqual(27, len(solver.pocket))
def test_Task2(self): solver = AoC() solver.data = ["1 + 2 * 3 + 4 * 5 + 6", "1 + (2 * 3) + (4 * (5 + 6))", "2 * 3 + (4 * 5)"] result = solver.Task2() self.assertEqual(328, result)
def test_Task1_1(self): solver = AoC() solver.data = [16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4] result = solver.Task1() self.assertEqual(35, result)
def test_Task2_2(self): solver = AoC() solver.data = [1, 3, 2] result = solver.Task2() self.assertEqual(2578, result)
def test_Task1(self): solver = AoC() solver.data = ["class: 1-3 or 5-7\nrow: 6-11 or 33-44\nseat: 13-40 or 45-50", "nearby tickets:\n7,3,47\n40,4,50\n55,2,20\n38,6,12"] solver.generateData() result = solver.Task1() self.assertEqual(71, result)
def test_Task2_4(self): solver = AoC() solver.data = [1, 2, 3] result = solver.Task2() self.assertEqual(261214, result)
def test_Task2(self): solver = AoC() solver.data = ["class: 0-1 or 4-19\nrow: 0-5 or 8-19\nseat: 0-13 or 16-19", "nearby tickets:\n3,9,18\n15,1,5\n5,14,9"] solver.generateData() result = solver.Task2()
def test_Task2_5(self): solver = AoC() solver.data = [2, 3, 1] result = solver.Task2() self.assertEqual(6895259, result)
def test_RuleGenerator(self): solver = AoC() solver.data = ["class: 1-3 or 5-7\nrow: 6-11 or 33-44\nseat: 13-40 or 45-50"] solver.generateData() self.assertEqual(3, len(solver.rules))
def test_Task2_7(self): solver = AoC() solver.data = [3, 1, 2] result = solver.Task2() self.assertEqual(362, result)
def test_Task2(self): solver = AoC() input_data = ["939", "7,13,x,x,59,x,31,19"] solver.generateDataset(input_data) result = solver.Task2() self.assertEqual(1068781, result)
def test_Task2_2(self): solver = AoC() input_data = ["939", "17,x,13,19"] solver.generateDataset(input_data) result = solver.Task2() self.assertEqual(3417, result)
def test_solveEquation(self): solver = AoC() result = solver.solveEquation("1 + 2 * 3 + 4 * 5 + 6") self.assertEqual(71, result)