Advent of Code: Day 15
Science for Hungry People

First puzzle

We are going to be a cookie chef on this puzzle. We have a set of ingredients as the puzzle input. Each ingredient has the five properties per ingredient spoon represented as integers: capacity, durability, flavor, texture, calories. All cookies need to be made of exactly 100 spoons. The cookie’s “quality” or score is the ingredient properties sum and then multiplied with the exception of the calories that is not used. If any property is negative, it becomes zero giving the total score of zero. The example from the puzzle description makes us understand the formula better.

Two ingredients:

The score of a cookie with 44 spoons of I1 and 56 spoons of I2 could:

Multiplying all the properties together, we find the score: 68 * 80 * 152 * 76 = 62842880. In this case, none of the properties was negative. It is very important to check for negative and make zero the property’s total sum not partial sums.

As usual, we need to do some parsing to convert the input string into an Ingredient case class:

We don’t have too many ingredients on the input. It is possible to generate all the possible combinations of 100 spoons, calculate their value on all the properties, calculate their score, and find the maximum to find our puzzle solution:

Second puzzle

For the second puzzle, we need to find the max score but taking into account cookies with 500 calories only:

You can find this code along with my input and puzzle answers at here.

*****
Written by Darien Martinez on 15 March 2016