Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active January 5, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/5631e1b37b5d7d557450 to your computer and use it in GitHub Desktop.
Save ghaiklor/5631e1b37b5d7d557450 to your computer and use it in GitHub Desktop.
Advent of Code (Day 2 Part 2)
const fs = require('fs');
const INPUT = fs.readFileSync('./input.txt', 'utf-8').split('\n');
const result = INPUT.reduce((total, _lwh) => {
const lwh = _lwh.split('x').map(Number).sort((a, b) => a - b);
return total
+ (lwh[0] + lwh[0] + lwh[1] + lwh[1])
+ (lwh[0] * lwh[1] * lwh[2])
}, 0);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment