adventofcode/2015/day15/problem

90 lines
3.4 KiB
Plaintext
Raw Permalink Normal View History

2018-03-15 16:24:23 +00:00
Advent of Code
2016-12-16 22:21:15 +00:00
--- Day 15: Science for Hungry People ---
2018-03-15 16:24:23 +00:00
Today, you set out on the task of perfecting your milk-dunking cookie
recipe. All you have to do is find the right balance of ingredients.
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a
list of the remaining ingredients you could use to finish the recipe (your
puzzle input) and their properties per teaspoon:
2016-12-16 22:21:15 +00:00
 capacity (how well it helps the cookie absorb milk)
2018-03-15 16:24:23 +00:00
2016-12-16 22:21:15 +00:00
 durability (how well it keeps the cookie intact when full of milk)
2018-03-15 16:24:23 +00:00
2016-12-16 22:21:15 +00:00
 flavor (how tasty it makes the cookie)
2018-03-15 16:24:23 +00:00
2016-12-16 22:21:15 +00:00
 texture (how it improves the feel of the cookie)
2018-03-15 16:24:23 +00:00
2016-12-16 22:21:15 +00:00
 calories (how many calories it adds to the cookie)
2018-03-15 16:24:23 +00:00
You can only measure ingredients in whole-teaspoon amounts accurately, and
you have to be accurate so you can reproduce your results in the future. The
total score of a cookie can be found by adding up each of the properties
(negative totals become 0) and then multiplying together everything except
calories.
2016-12-16 22:21:15 +00:00
For instance, suppose you have these two ingredients:
Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8
Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3
2018-03-15 16:24:23 +00:00
Then, choosing to use 44 teaspoons of butterscotch and 56 teaspoons of
cinnamon (because the amounts of each ingredient must add up to 100) would
result in a cookie with the following properties:
2016-12-16 22:21:15 +00:00
 A capacity of 44*-1 + 56*2 = 68
 A durability of 44*-2 + 56*3 = 80
 A flavor of 44*6 + 56*-2 = 152
 A texture of 44*3 + 56*-1 = 76
2018-03-15 16:24:23 +00:00
Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now)
results in a total score of 62842880, which happens to be the best score
possible given these ingredients. If any properties had produced a negative
total, it would have instead become zero, causing the whole score to
multiply to zero.
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
Given the ingredients in your kitchen and their properties, what is the
total score of the highest-scoring cookie you can make?
2016-12-16 22:21:15 +00:00
Your puzzle answer was 18965440.
--- Part Two ---
2018-03-15 16:24:23 +00:00
Your cookie recipe becomes wildly popular! Someone asks if you can make
another recipe that has exactly 500 calories per cookie (so they can use it
as a meal replacement). Keep the rest of your award-winning process the same
(100 teaspoons, same ingredients, same scoring system).
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
For example, given the ingredients above, if you had instead selected 40
teaspoons of butterscotch and 60 teaspoons of cinnamon (which still adds to
100), the total calorie count would be 40*8 + 60*3 = 500. The total score
would go down, though: only 57600000, the best you can do in such trying
circumstances.
2016-12-16 22:21:15 +00:00
2018-03-15 16:24:23 +00:00
Given the ingredients in your kitchen and their properties, what is the
total score of the highest-scoring cookie you can make with a calorie total
of 500?
2016-12-16 22:21:15 +00:00
Your puzzle answer was 15862900.
Both parts of this puzzle are complete! They provide two gold stars: **
2018-03-15 16:24:23 +00:00
At this point, you should return to your advent calendar and try another
puzzle.
2016-12-16 22:21:15 +00:00
If you still want to see it, you can get your puzzle input.
References
Visible links
. http://adventofcode.com/
. http://adventofcode.com/about
. http://adventofcode.com/stats
. http://adventofcode.com/leaderboard
. http://adventofcode.com/settings
. http://adventofcode.com/auth/logout
. http://adventofcode.com/
. http://adventofcode.com/day/15/input