Part 1
Description
The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (lengthl, width w, and height h)Fortunately, every present is a box (a perfect right rectangular prism), which makes calculating the required wrapping paper for each gift a little easier: find the surface area of the box, which is
2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each present: the area of the smallest side.For example:
- A present with dimensions 2x3x4requires2*6 + 2*12 + 2*8 = 52square feet of wrapping paper plus6square feet of slack, for a total of58square feet.
- A present with dimensions 1x1x10requires2*1 + 2*10 + 2*10 = 42square feet of wrapping paper plus1square foot of slack, for a total of43square feet.
Input
Solution
For this day's puzzle, I put the input (1000 of them) in the leftmost column. Then, I split them up into three parts: length, width, and height. Then to calculate the wrapping paper needed, i use this formula and sum up the result.=SUM(3*SMALL(C4:E4,1)*SMALL(C4:E4,2),2*SMALL(C4:E4,1)*SMALL(C4:E4,3),2*SMALL(C4:E4,3)*SMALL(C4:E4,2))
Basically, the formula define the smallest, the second smallest and the largest among the three parts. Then it calculates the surface area and extra wrapping paper by multiplying the two smallest area with three and two others with two and sum the result. Finally, I sum up all the wrapping paper needed for each present.
Part 2
Description
The elves are also running low on ribbon. Ribbon is all the same width, so they only have to worry about the length they need to order, which they would again like to be exact.The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face. Each present also requires a bow made out of ribbon as well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present. Don't ask how they tie the bow, though; they'll never tell.
For example:
- A present with dimensions 2x3x4requires2+2+3+3 = 10feet of ribbon to wrap the present plus2*3*4 = 24feet of ribbon for the bow, for a total of34feet.
- A present with dimensions 1x1x10requires1+1+1+1 = 4feet of ribbon to wrap the present plus1*1*10 = 10feet of ribbon for the bow, for a total of14feet.
Solution
Now, for the part two,using this formula,=2*SMALL(C4:E4,1)+2*SMALL(C4:E4,2)+C4*D4*E4
I can easily get the smallest perimeter and the volume.
 
 
 Posts
Posts
 
 
0 komentar:
Post a Comment