Exemplo n.º 1
0
    def test_greedy(self):
        """Test method for the greedy method."""
        for n in range(NUM_INSTANCES):
            instance = generate_instance(COLORS, TILES, LENGTH)

            print 'brute force'
            brute_force_solution = brute_force(instance)
            brute_force_score = score(brute_force_solution)
            print 'bf', brute_force_score, ':', brute_force_solution

            print 'greedy'
            greedy_solution = greedy(instance)
            greedy_score = score(greedy_solution)
            print 'gr', greedy_score, ':', greedy_solution

            self.assertEqual(greedy_score, brute_force_score)
Exemplo n.º 2
0
 def test_generate_instance(self):
     """Test method for the generate_instance method."""
     instance = generate_instance(3, 6, 2)
     expected = [(0, 0), (0, 1), (0, 2), (1, 1), (1, 2), (2, 2)]
     self.assertItemsEqual(instance, expected)