2015 day 2 part 1 complete

This commit is contained in:
Tristan 2018-11-29 17:57:48 +00:00
parent 22d09272e1
commit f3f4580176
2 changed files with 1023 additions and 0 deletions

1001
2015/2/input.txt Normal file

File diff suppressed because it is too large Load diff

22
2015/2/part1.js Normal file
View file

@ -0,0 +1,22 @@
const fs = require('fs');
let data = fs.readFileSync('input.txt', 'utf-8');
let lines = data.split('\n');
let amt = 0;
lines.forEach(line => {
let dim
try {
dim = line.match(/(\d+)x(\d+)x(\d+)/).splice(1,3);
}
catch (err) {
return 0;
}
let sides = []
sides[0] = dim[0]*dim[1];
sides[1] = dim[1]*dim[2];
sides[2] = dim[0]*dim[2];
let smallest = Math.min.apply(Math, sides);
amt += (sides[0]+sides[1]+sides[2])*2+smallest;
console.log(dim, sides, smallest, amt);
})
console.log(amt);