public void TestDoesnContainWord()
        {
            var anagram = new SortedAnagram("blu");
            var word = "blue";

            Assert.IsFalse(anagram.ContainsWord(word));
        }
        public void TestDoesnContainRepeatedChars()
        {
            var anagram = new SortedAnagram("act");
            var word = "aa";

            Assert.IsFalse(anagram.ContainsWord(word));
        }
        public void TestContainsWord()
        {
            var anagram = new SortedAnagram("act");
            var word = "cat";

            Assert.IsTrue(anagram.ContainsWord(word));
        }
        public void TestSubtractWord()
        {
            var anagram = new SortedAnagram("lolcat");
            var word = "cat";

            var expected = "llo";
            var actual = anagram.SubtractWord(word);

            Assert.AreEqual(expected, actual.ToString());
        }
        public void TestSolve()
        {
            var wordList = new List<string>
            {
                 "b", "see", "rat", "at", "mat", "rat", "lat", "tab", "green", "act", "a"
            }.ToArray();

            var anagram = new SortedAnagram("acatbat");
            var solver = new RecursiveAnagramFinder();

            var expected = new List<string> { "tab act a" };
            var actual = solver.Solve(anagram, wordList, 3);

            CollectionAssert.AreEqual(expected, actual);
        }
        public string Solve(string anagram, string[] wordList)
        {
            var maxNumWords = anagram.Count(x => x == ' ') + 1;
            var anagramToSolve = new SortedAnagram(anagram.Replace(" ", String.Empty));

            var result = _finder.Solve(anagramToSolve, wordList, maxNumWords);

            var solution = String.Empty;
            Parallel.ForEach(result, (potentialSolution, outerState) =>
            {
                var permutations = _permutator.Permutate(potentialSolution);
                Parallel.ForEach(permutations, (p, innerState) =>
                {
                    if (_verifier.IsASolution(p))
                    {
                        solution = p;
                        outerState.Stop();
                        innerState.Stop();
                    }
                });
            });

            return solution;
        }