Skip to content

Instantly share code, notes, and snippets.

@Trinitek
Last active January 25, 2022 05:51
Show Gist options
  • Select an option

  • Save Trinitek/5c674fccac2ee27e7d6c178d75d83613 to your computer and use it in GitHub Desktop.

Select an option

Save Trinitek/5c674fccac2ee27e7d6c178d75d83613 to your computer and use it in GitHub Desktop.
void Main()
{
string dict = @"C:\Users\Trinitek\Downloads\hunspell-en_US-2020.12.07\en_US.dic";
var words = File.ReadLines(dict)
.Skip(1)
.Select(l => string.Concat(l.ToLower().TakeWhile(c => c != '/')))
.Where(l => l.Length == 5)
.ToList();
char[] nope =
"aboutdves"
.ToArray();
var isNotPos = new Dictionary<int, char[]>()
{
[0] = new char[] { 'p' },
[4] = new char[] { 'm' }
};
string foundPositions =
"_rim_";
var isPos = new Dictionary<int, char>(
foundPositions.Select((c, index) => KeyValuePair.Create(index, c)).Where(kvp => kvp.Value != '_'));
words.Where(w =>
!nope.Intersect(w).Any()
&& isNotPos.Aggregate(seed: true, (next, kvp) => next && !kvp.Value.Contains(w[kvp.Key]))
&& (isNotPos.Any()
? w.Intersect(isNotPos.SelectMany(kvp => kvp.Value).Distinct()).Count()
== isNotPos.SelectMany(kvp => kvp.Value).Distinct().Count()
: true)
&& isPos.Aggregate(seed: true, (next, kvp) => next && w[kvp.Key] == kvp.Value)
).Dump();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment