Created
December 7, 2015 05:44
-
-
Save kevinkace/2af25e2b63df59b02827 to your computer and use it in GitHub Desktop.
Advent of Code - 5b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var names = document.querySelector("pre").innerHTML.trim(), | |
niceCount = 0; | |
function vowelCheck(name) { | |
var count = name.match(/[aeiou]/gi); | |
return count && count.length >= 3; | |
} | |
function doubleCheck(name) { | |
return /(.)\1/.test(name); | |
} | |
function excludeCheck(name) { | |
return !/ab|cd|pq|xy/.test(name); | |
} | |
function doubleDouble(name) { | |
return /(..).*?\1/.test(name); | |
} | |
function simplePalindrome(name) { | |
return /(.).\1/.test(name); | |
} | |
console.log(names.split("\n").filter(function(name, idx) { | |
var result = doubleDouble(name) && simplePalindrome(name); | |
console.log(name + ":" + result); | |
return result; | |
}).length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment