adventofcode-2018/02/part1.js

5 lines
341 B
JavaScript
Raw Normal View History

2018-12-02 18:13:52 +00:00
var strs = require("fs").readFileSync("input.txt").toString().split("\n").filter((a)=>(a));
var pairs = strs.filter((str)=>(str.match(/([a-z]).*\1(?<!\1.*\1.*\1)(?!.*\1)/))).length;
var triples = strs.filter((str)=>(str.match(/([a-z]).*\1.*\1(?<!\1.*\1.*\1.*\1)(?!.*\1)/))).length;
console.log(strs.length, pairs, triples, pairs * triples);