def test_score(self): """Test method for the score method.""" layout = [(1, 2, 3), (3, 4, 5), (5, 6, 7)] self.assertEqual(score(layout), 7) layout = [(1, 2, 3), (2, 3, 4), (3, 4, 5)] self.assertEqual(score(layout), 5) layout = [(1, 1), (1, 1), (1, 1)] self.assertEqual(score(layout), 2)
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)