Advent of Code: Day 2
I Was Told There Would Be No Math

First puzzle

This time, we need to calculate the wrapping paper to wrap a list gifts. The gifts are boxes, and the paper will wrap all the boxes entirely. In addition to the box area, an extra piece of paper the size of the smaller side is needed as well. The following are the examples given in the puzzle description:

Our input is a string with the gift’s length(l), width(w) and height(h) separated by “x”. For example, 10x20x30\n30x20x10 for two boxes.

First, we need to parse the input:

Based on that parsing, we can map the array of sides to the area of sides. Then sum all the sides area plus the smaller one:

Second puzzle

For the second puzzle, the gifts ribbon and bow length needs to be calculated. The ribbon is the smaller perimeter on any surface and the bow is equaled to the value of the gift volume. For the examples above:

Here is the code:

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

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