コード例 #1
0
 def test_render_horizontal_vein(self):
     self.assertEqual(
         str(scan_input("y=7, x=495..501")), """
         ......+..
         .........
         .........
         .........
         .........
         .........
         .........
         .#######.
         """.strip().replace(" ", ""))
コード例 #2
0
 def test_render_vertical_vein(self):
     self.assertEqual(
         str(scan_input("x=495, y=2..7")), """
         ......+.
         ........
         .#......
         .#......
         .#......
         .#......
         .#......
         .#......
         """.strip().replace(" ", ""))
コード例 #3
0
    def test_water_falling_on_flowing_water(self):
        reservoir = scan_input("""
y=3, x=500..500
y=5, x=499..501
            """.strip())
        reservoir.flow(14)
        self.assertEqual(
            str(reservoir), """
            ..+..
            ..|..
            .|||.
            .|#|.
            |||||
            |###|
            """.strip().replace(' ', ''))
コード例 #4
0
 def test_render_example(self):
     self.assertEqual(
         str(scan_input(EXAMPLE_INPUT)), """
         ......+.......
         ............#.
         .#..#.......#.
         .#..#..#......
         .#..#..#......
         .#.....#......
         .#.....#......
         .#######......
         ..............
         ..............
         ....#.....#...
         ....#.....#...
         ....#.....#...
         ....#######...
         """.strip().replace(' ', ''))
コード例 #5
0
 def test_flow_step_2(self):
     reservoir: Reservoir = scan_input(EXAMPLE_INPUT)
     reservoir.flow(2)
     self.assertEqual(
         str(reservoir), """
         ......+.......
         ......|.....#.
         .#..#.|.....#.
         .#..#..#......
         .#..#..#......
         .#.....#......
         .#.....#......
         .#######......
         ..............
         ..............
         ....#.....#...
         ....#.....#...
         ....#.....#...
         ....#######...
         """.strip().replace(' ', ''))
コード例 #6
0
 def test_flow_step_57_dry(self):
     reservoir: Reservoir = scan_input(EXAMPLE_INPUT)
     reservoir.flow(58)
     reservoir.dry()
     self.assertEqual(
         str(reservoir), """
         ..............
         ............#.
         .#..#.......#.
         .#..#||#......
         .#..#||#......
         .#|||||#......
         .#|||||#......
         .#######......
         ..............
         ..............
         ....#|||||#...
         ....#|||||#...
         ....#|||||#...
         ....#######...
         """.strip().replace(' ', ''))
コード例 #7
0
    def test_water_falling_on_water_at_same_hight_as_top_of_water_fall(self):
        reservoir = scan_input("""
y=3, x=500..502
x=501, y=5..6
y=7, x=499..501
x=504, y=6..7
y=8, x=499..504
            """.strip())
        reservoir.flow(30)
        self.assertEqual(
            str(reservoir), """
            ..+.....
            ..|.....
            .|||||..
            .|###|..
            .|...|..
            .|.#||||
            |||#||#|
            |###||#|
            |######|
            """.strip().replace(' ', ''))
コード例 #8
0
 def test_count_water(self):
     reservoir: Reservoir = scan_input(EXAMPLE_INPUT)
     reservoir.flow(58)
     self.assertEqual(reservoir.count_water(), 57)