adventofcode-2017/day01/part2.js

4 lines
241 B
JavaScript
Raw Normal View History

2017-12-01 14:23:17 +00:00
var input = require("fs").readFileSync("input.txt").toString().replace("\n", "");
var chars = input.split("").map((a)=>(parseInt(a)));
console.log(chars.filter((a, i)=>(chars[(i+(chars.length/2))%chars.length] == a)).reduce((a, b)=>(a+b)));