adventofcode-2018/01/part2.js
2018-12-02 18:18:10 +00:00

17 lines
304 B
JavaScript

var input = require("fs").readFileSync("input.txt").toString();
var nums = input.split("\n").filter(a=>(a)).map(a=>(parseInt(a)));
var seen = {};
var total = 0;
while(true){
for(var i of nums){
total += i;
if(!seen[total]){
seen[total]=1;
}
else{
console.log(total);
return 0;
}
}
}