Exemplo n.º 1
0
        public void FindWords(Words dictionary)
        {
            if (dictionary.LetterCount <= m_letterCount)
            {
                // check the used words
                for (int i = 0; i < dictionary.CountUsed; i++)
                {
                    string baseWord = m_baseWord;
                    string compareWord = dictionary.GetUsedWord(i);
                    bool found = true;
                    while (found && compareWord.Length > 0)
                    {
                        int index = baseWord.IndexOf(compareWord[0]);
                        if (index >= 0)
                        {
                            baseWord = baseWord.Remove(index, 1);
                            compareWord = compareWord.Remove(0, 1);
                        }
                        else
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        string word = dictionary.GetWord(i);
                        m_wordList.Add(word);
                    }
                }

                // check the unused words
                for (int i = 0; i < dictionary.Count; i++)
                {
                    string baseWord = m_baseWord;
                    string compareWord = dictionary.GetWord(i);
                    bool found = true;
                    while (found && compareWord.Length > 0)
                    {
                        int index = baseWord.IndexOf(compareWord[0]);
                        if (index >= 0)
                        {
                            baseWord = baseWord.Remove(index, 1);
                            compareWord = compareWord.Remove(0, 1);
                        }
                        else
                        {
                            found = false;
                            break;
                        }
                    }
                    if (found)
                    {
                        string word = dictionary.GetWord(i);
                        m_wordList.Add(word);
                    }
                }

            }
        }
Exemplo n.º 2
0
 private static Occurrences SentenceOccurrences(Words words)
 {
     return(WordOccurrences(string.Concat(words)));
 }