9
1
Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to figure out the expenses for how much to pay them.
Challenge
Given some information for the presents, determine the cost of manufacturing all of them.
Each present is put in a cardboard box and wrapped with wrapping paper, with a ribbon wrapped around it at the very end. The wrapping paper is magical and requires no overlap, so the amount of wrapping paper used is precisely equivalent to the surface area of the box. All presents are rectangular prisms because that way Santa can store them more compactly. The ribbon goes around in all three directions (so the length of ribbon used for wrapping is equal to the sum of the three different perimeters).
The present itself has a known cost, fortunately. Cardboard costs $1 per square meter, and wrapping paper costs $2 per square meter. (Hint: You can just multiply the surface area by 3 :P). Ribbon costs $1 per meter.
Format Specifications
The input will be given as a list of presents where each present contains the cost of the actual item and the three dimensions of the present box. Your output should be the total cost required.
To be exact, the formula for the cost of a single present with item cost c
and dimensions x
, y
, and z
is c + 6 * (x * y + y * z + z * x) + 4 * (x + y + z)
.
Test Cases
[[7, 8, 6, 7], [7, 7, 5, 5], [8, 9, 6, 7], [6, 5, 10, 10], [5, 9, 6, 7], [9, 9, 10, 6], [8, 10, 10, 6], [6, 5, 7, 9], [7, 10, 8, 8], [5, 9, 9, 10]] -> 11866
[[5, 10, 8, 9], [8, 8, 5, 8], [8, 7, 7, 6], [5, 9, 9, 10], [9, 7, 5, 8], [9, 8, 9, 5], [7, 5, 6, 7], [5, 7, 6, 10]] -> 8854
[[9, 8, 8, 8], [10, 9, 8, 5], [10, 7, 5, 5], [10, 10, 6, 6], [8, 5, 8, 7]] -> 4853
[[7, 7, 8, 10], [8, 10, 7, 8], [9, 7, 7, 8], [8, 5, 10, 5], [6, 6, 6, 8], [8, 9, 7, 5], [8, 5, 6, 5], [7, 9, 8, 5], [10, 10, 10, 8]] -> 9717
[[5, 8, 9, 7], [5, 8, 7, 10], [5, 7, 7, 6], [5, 5, 5, 6], [9, 9, 5, 7], [5, 6, 7, 8], [8, 5, 8, 7], [6, 9, 5, 5], [10, 10, 9, 10]] -> 9418
[[9, 9, 7, 10], [5, 8, 7, 9], [5, 5, 9, 8], [10, 5, 9, 10], [8, 5, 10, 7], [8, 9, 5, 5], [5, 10, 6, 10]] -> 8178
[[5, 9, 5, 8], [7, 8, 10, 6], [7, 10, 7, 10], [8, 9, 7, 5], [5, 7, 8, 6], [9, 9, 6, 10], [6, 5, 9, 9], [7, 9, 9, 9]] -> 9766
[[7, 10, 5, 10], [8, 10, 8, 9], [8, 6, 7, 8], [6, 9, 8, 5], [6, 7, 10, 9], [7, 6, 5, 8]] -> 7118
[[10, 6, 7, 5], [5, 9, 5, 9], [9, 7, 8, 5], [6, 6, 9, 9], [9, 9, 6, 9], [10, 5, 8, 9], [7, 5, 6, 10], [9, 10, 5, 5]] -> 8007
[[8, 10, 7, 8], [9, 10, 5, 8], [6, 7, 5, 6], [10, 10, 9, 8], [7, 5, 8, 9], [10, 10, 6, 7], [10, 8, 9, 10], [5, 10, 5, 5]] -> 9331
Rules
- Standard Loopholes Apply
- The input and output may be given and presented in any reasonable format
- You must take the input as a list of presents, not 4 lists of the attributes.
- This is a code-golf, so the shortest answer in bytes wins
- No answers will be accepted
Hopefully this challenge is easier than the previous ones :P
Note: I drew inspiration for this challenge series from Advent Of Code. I have no affiliation with this site
You can see a list of all challenges in the series by looking at the 'Linked' section of the first challenge here.
Have we lost the "additional 1 meter for the ribbon" in
c + 6 * (x * y + y * z + z * x) + 4 * (x + y + z)
– Graham – 2017-12-03T21:58:55.847@Graham Yeah, turns out I forgot to add that in. Removing from specifications. – HyperNeutrino – 2017-12-03T22:27:22.060
@cairdcoinheringaahing Sorry for the confusion. I decided to stick with the original idea and I have edited my test cases to reflect that as well. Thanks! – HyperNeutrino – 2017-12-03T22:30:53.530
@dzaima Yes, the test cases were done last-minute, sorry about that :P I have fixed them. – HyperNeutrino – 2017-12-03T22:31:07.237
@JonathanFrech Done, thanks. (See ^ and ^^) – HyperNeutrino – 2017-12-03T22:31:14.550
6I've been enjoying this series of challenges but (admittedly, after a good few beers!) this one just seems like which language can execute the closed formula in the fewest bytes without any room for creative golfing so, in this instance, no +1 from me. – Shaggy – 2017-12-03T22:40:28.270
@Shaggy Glad you've been enjoying it up to this point! This one was admittedly not very well thought out (given also by the fact that I made at least two internal consistency errors); it was made very last-minute. Completely understandable :) Hopefully I'll plan them out better in the future :P I should probably start writing them out the night before :P – HyperNeutrino – 2017-12-03T22:42:45.503
1To the extra close-voter after I clarified the existing commented points, what more should I clarify? – HyperNeutrino – 2017-12-04T01:26:15.143