private static void RunAnagram2B(WrappingWriter writer, List <string> words, List <string> wordTest) { Stopwatch swSearch = new Stopwatch(); Stopwatch swElapsed = new Stopwatch(); ICombinator <char> combinator = new GenericCombinator <char>(); Anagram2 anagram = new Anagram2(combinator, words); writer.WriteLine($"{Environment.NewLine}Running Anagram2B"); swElapsed.Start(); swSearch.Start(); var anagrams = anagram.FindAll(wordTest); swSearch.Stop(); foreach (var pair in anagrams) { writer.Write($"{pair.Key}:"); foreach (var result in pair.Value) { writer.Write($@" {result}"); } writer.WriteLine(); } swElapsed.Stop(); writer.WriteLine($"{Environment.NewLine}Anagram2B completed! {Environment.NewLine}\tSearchTime: {swSearch.Elapsed}{Environment.NewLine}\tElapsed Time: {swElapsed.Elapsed}"); writer.WriteLine($"Number of words: {words.Count}"); writer.WriteLine($"Number of words to test: {wordTest.Count}"); writer.WriteLine($"Number of anagram pairs: {anagrams.Count}"); }
private static void RunAnagram(WrappingWriter writer, List <string> words, List <string> wordTest, IMediator mediator) { Stopwatch stopwatch = new Stopwatch(); Anagram anagram = new Anagram(writer, mediator); GenericCombinator <char> combinations = new GenericCombinator <char>(); writer.WriteLine($"{Environment.NewLine}Running Anagram"); stopwatch.Start(); foreach (var word in wordTest) { writer.Write($"{word}:"); anagram.FindAll(word); writer.WriteLine(); } stopwatch.Stop(); writer.WriteLine($"{Environment.NewLine}Done in {stopwatch.ElapsedMilliseconds}ms!"); }
private static void RunAnagram2A(WrappingWriter writer, List <string> words, List <string> wordTest) { Stopwatch stopwatch = new Stopwatch(); ICombinator <char> combinator = new GenericCombinator <char>(); Anagram2 anagram = new Anagram2(combinator, words); writer.WriteLine($"{Environment.NewLine}Running Anagram2A"); stopwatch.Start(); foreach (var word in wordTest) { writer.Write($"{word}:"); var results = anagram.FindAll(word); foreach (var result in results) { writer.Write($@" {result}"); } writer.WriteLine(); } stopwatch.Stop(); writer.WriteLine($"{Environment.NewLine}Done in {stopwatch.ElapsedMilliseconds}ms!"); }
private static void RunCombinator(WrappingWriter writer, List <string> wordTest, IMediator mediator) { Stopwatch stopwatch = new Stopwatch(); GenericCombinator <char> combinations = new GenericCombinator <char>(); writer.WriteLine($"{Environment.NewLine}Running Combinator"); stopwatch.Start(); foreach (var word in wordTest) { writer.Write($"{word}:"); var combos = combinations.FindCombinations(word.ToCharArray()); foreach (var combo in combos) { mediator.Publish(new ComboFound { Combo = new string(combo) }).Wait(); } writer.WriteLine(); } stopwatch.Stop(); writer.WriteLine($"{Environment.NewLine}Done in {stopwatch.ElapsedMilliseconds}ms!"); }