Metadata
-
Date
-
Tagged
-
Part of series
-
Older post
-
Newer post
Advent of Code 2015 Day 2
Day 2: I Was Told There Would Be No Math
https://adventofcode.com/2015/day/2
The elves would like to order the exact amount of wrapping paper they need to wrap all presents.
Each present is a perfectly rectangular box.
Today’s input is a list with the dimensions of each gift.
An example input looks like this:
Each line has the form of LxWxH
.
For the first present in the list above:
- length: 29
- width: 13
- height: 26
Those numbers are unitless. Let’s say Santa uses the imperial system to measure presents. They’re measured in feet.
Part 1
The required amount of wrapping paper for one present:
- Enough to cover all sides
- Some extra: the area of the smallest side
The question asks how many square foot of wrapping paper is needed to wrap all presents.
Main code for part 1
Part 2
The elves need to order ribbon too.
The required amount of ribbon for one present:
- Enough to wrap around the smallest perimeter
- Some extra for a bow: the cubic feet of volume for the present
The question asks how many feet of ribbon is needed to wrap all presents with a bow.
A minor change from part 1: I sorted the dimensions to be able to use the 2 smallest ones.