Last active
December 4, 2017 23:04
-
-
Save sclark39/a3e9b7d1548e861450002677e76847a2 to your computer and use it in GitHub Desktop.
Solution to the Advent of Code 2017 Day 4
This file contains hidden or 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 passphrases = input.split('\n') | |
function countValid( passphrases, allowAnagrams ) | |
{ | |
return passphrases.reduce( (s,passphrase) => { | |
var passwords = passphrase.split(' ') | |
passwords = allowAnagrams ? passwords : passwords.map( a => ( a.split('').sort().join('') ) ) | |
return s + passwords.reduce( ( s,n,i,a ) => s && a.indexOf(n) == i ) | |
}, 0 ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey, i do the input, and made input.split like you instruct. How should i call the function and see the result?