Created
December 4, 2015 20:02
-
-
Save BigAB/93c67773d688db9482e0 to your computer and use it in GitHub Desktop.
Advent of code day 2 answer - adventofcode.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculateWrappingPaperNeeds(input) { | |
return input.split('\n') | |
.reduce((sqFt, eq) => { | |
var d = eq.split('x'); | |
var l = d[0], w = d[1], h = d[2]; | |
sqFt += 2*l*w + 2*w*h + 2*h*l; | |
sqFt += Math.min(l*w, w*h, h*l); // little extra | |
return sqFt; | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment