Skip to content

Instantly share code, notes, and snippets.

@BigAB
Created December 4, 2015 20:02
Show Gist options
  • Save BigAB/93c67773d688db9482e0 to your computer and use it in GitHub Desktop.
Save BigAB/93c67773d688db9482e0 to your computer and use it in GitHub Desktop.
Advent of code day 2 answer - adventofcode.com
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