Example #1
0
    def print_labyrinth(self):
        from day13 import Day13
        import numpy as np

        IDs = [node.get_ID() for node in self.nodes]
        x_vals = [ID[0] for ID in IDs]
        y_vals = [ID[1] for ID in IDs]
        max_x = max(x_vals) + 2
        max_y = max(y_vals) + 2
        d13 = Day13(inp=self._input)

        board = d13.solve(w=max_x, h=max_y)
        shape = board.shape
        sc = len(str(board.shape[1]))
        s = " " * sc
        s += "".join(
            [str(x // 10) if x // 10 else ' ' for x in range(shape[0])]) + '\n'
        s += sc * " " + "".join([str(x % 10) for x in range(shape[0])]) + '\n'

        for y in range(max_y):
            s += str(y) + '_' * (sc - 1) if not y // 10 else str(y)
            for x in range(max_x):
                if x == 1 and y == 1:
                    s += "X"
                elif (x, y) == self._target:
                    s += 'O'
                elif (x, y) in IDs:
                    s += '.'
                else:
                    s += "#" if board[x, y] else " "
            s += "\n"
        return s[:-1]
Example #2
0
 def test_part1(self):
     self.assertEqual(Day13.solve_part1(self.input, dst=(7, 4)), 11)
Example #3
0
 def setUp(self) -> None:
     self.input = Day13().read_file("tests/test_day13.txt")
Example #4
0
 def test_part2(self):
     outputs = [1068781,3417,754018,779210,1261476,1202161486]
     for i,output in enumerate(outputs):
         input = Day13().read_file(f"tests/test_day13.{i+2}.txt")
         self.assertEqual(Day13.solve_part2(input),output)
Example #5
0
 def test_part1(self):
     input = Day13().read_file("tests/test_day13.1.txt")
     self.assertEqual(Day13.solve_part1(input),295)
Example #6
0
 def test_part1(self):
     self.assertEqual(Day13.solve_part1(self.input),330)
Example #7
0
 def test_part1(self) -> None:
     output = 24
     actual = Day13.solve_part1(self.input)
     self.assertEqual(
         actual, output,
         f"input={self.input}, expected={output}, actual={actual}")