Beispiel #1
0
 def test_Part2(self):
     grid = problem11.ParseInput(EXAMPLE_1)
     grid2 = grid.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(grid2, EXAMPLE_2_STEP_2)
     grid3 = grid2.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(grid3, EXAMPLE_2_STEP_3)
     grid4 = grid3.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(grid4, EXAMPLE_2_STEP_4)
     grid5 = grid4.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(grid5, EXAMPLE_2_STEP_5)
     grid6 = grid5.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(grid6, EXAMPLE_2_STEP_6)
     converged = grid6.Step(
         get_neighbors=problem11.AllVisible, leave_threshold=5
     )
     self.assertGridsEqual(
         converged,
         converged.Step(
             get_neighbors=problem11.AllVisible, leave_threshold=5
         ),
     )
     self.assertGridsEqual(converged, EXAMPLE_2_CONVERGED)
Beispiel #2
0
 def test_Convergence(self):
     grid = problem11.ParseInput(EXAMPLE_1)
     converged = grid.RunToConvergence()
     self.assertGridsEqual(converged, EXAMPLE_1_CONVERGED)
     self.assertEqual(
         sum(cell == "#" for cell in converged.data.values()), 37
     )
Beispiel #3
0
 def test_Step(self):
     grid = problem11.ParseInput(EXAMPLE_1)
     grid2 = grid.Step()
     self.assertGridsEqual(grid2, EXAMPLE_1_STEP_2)
     grid3 = grid2.Step()
     self.assertGridsEqual(grid3, EXAMPLE_1_STEP_3)
     grid4 = grid3.Step()
     self.assertGridsEqual(grid4, EXAMPLE_1_STEP_4)
     grid5 = grid4.Step()
     self.assertGridsEqual(grid5, EXAMPLE_1_STEP_5)
     converged = grid5.Step()
     self.assertGridsEqual(converged, converged.Step())
     self.assertGridsEqual(converged, EXAMPLE_1_CONVERGED)
Beispiel #4
0
 def test_Small(self):
     grid = problem11.ParseInput("LLL#")
     grid2 = grid.Step()
     self.assertGridsEqual(grid2, "##L#")
Beispiel #5
0
 def test_ParseAndPrettyPrint(self):
     grid = problem11.ParseInput(EXAMPLE_1)
     self.assertGridsEqual(grid, EXAMPLE_1)