public static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("usage: dotnet run min_word_length max_word_count"); } var minWordLength = int.Parse(args[0]); var maxWordCount = int.Parse(args[1]); var map = new CharacterCountMap(searchText); var wordlist = LoadWordlist(minWordLength, map); //foreach(var anagram in Anagrams.Find(wordlist, map, maxWordCount)) Parallel.ForEach(wordlist, x => { Console.WriteLine("Processing subtree for {0}", x); foreach (var anagram in Anagrams.Find( wordlist.Where(y => y != x), map.Subtract(x), maxWordCount - 1)) { var final = x + " " + anagram; Console.WriteLine(final); CheckForMatch(final); } }); }
public static IEnumerable <string> LoadWordlist(int minWordLength, CharacterCountMap map) { var lines = File.ReadAllLines("wordlist2").Distinct(); Console.WriteLine("Original wordlist has {0} unique elements.", lines.Count()); var filtered = lines .Where(x => x.Length >= minWordLength) .Where(x => map.Subtract(x) != null); Console.WriteLine( "There are {0} elements >= {1} letters long, that are contained in the map.", filtered.Count(), minWordLength); return(filtered); }