コード例 #1
0
    def setUp(self):
        example = """.#.#.#
...##.
#....#
..#...
#.#..#
####.."""
        self.grid = convert_string_to_grid(example)
コード例 #2
0
    def test_convert_example_string(self):
        example = """.#.#.#
...##.
#....#
..#...
#.#..#
####.."""
        grid = convert_string_to_grid(example)
        self.assertEqual(example, str(grid))
コード例 #3
0
    def test_example_2(self):
        grid = convert_string_to_grid(
            """##.#.#
...##.
#....#
..#...
#.#..#
####.#"""
        )
        expect = """##.###
.##..#
.##...
.##...
#.#...
##...#"""
        print grid
        for _ in range(5):
            grid.step_with_stuck_lights()
        print
        print grid
        self.assertEqual(expect, str(grid))
コード例 #4
0
 def test_puzzle_2(self):
     grid = convert_string_to_grid(INPUT_STRING)
     for _ in range(100):
         grid.step_with_stuck_lights()
     print grid.get_num_lights()