Example #1
0
 def test_multiple_steps(self):
     operators = [AddOperator(1), MultiplyOperator(20), DivideOperator(3)]
     problem = Problem(start_number=2,
                       end_number=1,
                       move_count=2,
                       operators=operators)
     solution = random_solve(problem)
     self.assertEqual(solution, [AddOperator(1), DivideOperator(3)])
Example #2
0
 def test_only_option(self):
     operators = [AddOperator(3)]
     problem = Problem(start_number=2,
                       end_number=5,
                       move_count=1,
                       operators=operators)
     solution = random_solve(problem)
     self.assertEqual(solution, [AddOperator(3)])
Example #3
0
 def test_str_negative(self):
     string = str(AddOperator(-5))
     self.assertEqual(string, "[ - 5 ]")
Example #4
0
 def test_str_positive(self):
     string = str(AddOperator(3))
     self.assertEqual(string, "[ + 3 ]")
Example #5
0
 def test_add_negative(self):
     state = State(current_number=5)
     state.apply(AddOperator(-8))
     self.assertEqual(state.current_number, -3)
Example #6
0
 def test_add_positive(self):
     state = State(current_number=10)
     state.apply(AddOperator(5))
     self.assertEqual(state.current_number, 15)
Example #7
0
 def test_add_zero(self):
     state = State(current_number=2)
     state.apply(AddOperator(0))
     self.assertEqual(state.current_number, 2)