Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active January 5, 2016 16:05
Show Gist options
  • Save ghaiklor/d3fd4578cdeedc54136c to your computer and use it in GitHub Desktop.
Save ghaiklor/d3fd4578cdeedc54136c to your computer and use it in GitHub Desktop.
Advent of Code (Day 2 Part 1)
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');
const length = lwh[0];
const width = lwh[1];
const height = lwh[2];
return total
+ (2 * length * width)
+ (2 * width * height)
+ (2 * height * length)
+ Math.min(length * width, width * height, height * length);
}, 0);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment