Skip to content

Instantly share code, notes, and snippets.

@csuzw
Last active December 4, 2017 15:20
Embed
What would you like to do?
Advent of Code 2017 Day 4
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