Advent of Code 2017 Day 4
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
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