5 lines
410 B
JavaScript
5 lines
410 B
JavaScript
|
aba=(s)=>(s.split("").reduce((a, b, i, c)=>{if(((c[i] == c[i - 2]) && (c[i] != c[i - 1]))){a.push(c[i-1] + c[i] + c[i-1]);} return a;}, []));
|
||
|
var input = require("fs").readFileSync("input.txt").toString().replace(/\r/g, "");
|
||
|
var ips = input.split("\n").filter((s)=>(aba(s.split(/\[[^\]]+\]/g).join("")).reduce((a, b)=>((s.match(/\[[^\]]+\]/g).join("").indexOf(b) != -1) || a), false)))
|
||
|
console.log(ips.length)
|