Last active
January 25, 2022 05:51
-
-
Save Trinitek/5c674fccac2ee27e7d6c178d75d83613 to your computer and use it in GitHub Desktop.
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
| 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