Last active
December 4, 2017 15:20
-
-
Save csuzw/b1478da9ee4c5caa4b86045a8b8dace7 to your computer and use it in GitHub Desktop.
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
int HighEntropyPassphrasesPartOne(string[] passPhrases) | |
{ | |
return DoHighEntropyPassphrases(passPhrases, w => w); | |
} | |
int HighEntropyPassphrasesPartTwo(string[] passPhrases) | |
{ | |
return DoHighEntropyPassphrases(passPhrases, w => string.Concat(w.OrderBy(c => c))); | |
} | |
int DoHighEntropyPassphrases(string[] passPhrases, Func<string, string> map) | |
{ | |
return passPhrases.Count(words => | |
{ | |
var set = new HashSet<string>(); | |
return words.Split(' ').All(word => set.Add(map(word))); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment