예제 #1
0
 def test_auto_bake(self):
     ingredients = [
         "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
         "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3"
     ]
     solver = SolutionFifteen(ingredients)
     cookie = solver.bake()
     self.assertEqual(62842880, cookie.score)
예제 #2
0
 def test_auto_bake(self):
     ingredients = [
         "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
         "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3",
     ]
     solver = SolutionFifteen(ingredients)
     cookie = solver.bake()
     self.assertEqual(62842880, cookie.score)
예제 #3
0
    def test_cookie(self):
        ingredients = [
            "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
            "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3"
        ]
        solver = SolutionFifteen(ingredients)
        solver.add_ingredient("Cinnamon", 100)

        self.assertEqual(100, solver.cookie.spoons)
        self.assertEqual(-200, solver.cookie.flavor)
        self.assertEqual(300, solver.cookie.calories)
예제 #4
0
    def test_cookie(self):
        ingredients = [
            "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
            "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3",
        ]
        solver = SolutionFifteen(ingredients)
        solver.add_ingredient("Cinnamon", 100)

        self.assertEqual(100, solver.cookie.spoons)
        self.assertEqual(-200, solver.cookie.flavor)
        self.assertEqual(300, solver.cookie.calories)
예제 #5
0
    def test_case(self):
        ingredients = [
            "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
            "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3",
        ]
        solver = SolutionFifteen(ingredients)
        solver.add_ingredient("Cinnamon", 56)
        solver.add_ingredient("Butterscotch", 44)
        self.assertEqual(44 * -1 + 56 * 2, solver.cookie.capacity)
        self.assertEqual(44 * -2 + 56 * 3, solver.cookie.durability)
        self.assertEqual(44 * 6 + 56 * -2, solver.cookie.flavor)
        self.assertEqual(44 * 3 + 56 * -1, solver.cookie.texture)

        self.assertEqual(62842880, solver.cookie.score)
예제 #6
0
    def test_case(self):
        ingredients = [
            "Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
            "Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3"
        ]
        solver = SolutionFifteen(ingredients)
        solver.add_ingredient("Cinnamon", 56)
        solver.add_ingredient("Butterscotch", 44)
        self.assertEqual(44 * -1 + 56 * 2, solver.cookie.capacity)
        self.assertEqual(44 * -2 + 56 * 3, solver.cookie.durability)
        self.assertEqual(44 * 6 + 56 * -2, solver.cookie.flavor)
        self.assertEqual(44 * 3 + 56 * -1, solver.cookie.texture)

        self.assertEqual(62842880, solver.cookie.score)
예제 #7
0
from SolutionFifteen import SolutionFifteen

ingredient_descriptions = [
    "Frosting: capacity 4, durability -2, flavor 0, texture 0, calories 5",
    "Candy: capacity 0, durability 5, flavor -1, texture 0, calories 8",
    "Butterscotch: capacity -1, durability 0, flavor 5, texture 0, calories 6",
    "Sugar: capacity 0, durability 0, flavor -2, texture 2, calories 1"
]
solver = SolutionFifteen(ingredient_descriptions)
cookie = solver.bake()
print "*********************"
print " Winning cookie: %s" % cookie
print "  Score: %d" % cookie.score
print "*********************"
예제 #8
0
from SolutionFifteen import SolutionFifteen


ingredient_descriptions = [
    "Frosting: capacity 4, durability -2, flavor 0, texture 0, calories 5",
    "Candy: capacity 0, durability 5, flavor -1, texture 0, calories 8",
    "Butterscotch: capacity -1, durability 0, flavor 5, texture 0, calories 6",
    "Sugar: capacity 0, durability 0, flavor -2, texture 2, calories 1"
]
solver = SolutionFifteen(ingredient_descriptions)
cookie = solver.bake()
print "*********************"
print " Winning cookie: %s" % cookie
print "  Score: %d" % cookie.score
print "*********************"