adventofcode-2017/day02/part2.js

5 lines
334 B
JavaScript
Raw Permalink Normal View History

2017-12-02 12:59:01 +00:00
var input = require("fs").readFileSync("input.txt").toString();
var rows = input.split("\n").filter((a)=>(a)).map((a)=>(a.split("\t").map((b)=>(parseInt(b)))));
2017-12-02 13:39:23 +00:00
var divis = rows.map((a)=>(a.map((b)=>(a.map((c)=>(b/c)).filter((c)=>(c%1 == 0)).filter((c)=>(c!=1))[0])).filter((c)=>(c)))[0]);
console.log(divis.reduce((a, b)=>(a + b)));