Exemple #1
0
        void FillRowInRectangle(WordsMatrix wordsRectangle, WordsMatrix.Location row, WordsMatrix.Location column,
                                Trie rowWords, Trie columnWords, string rowWord)
        {
            if (wordsRectangle.IsFull)
            {
                return;
            }

            if (wordsRectangle.FillRow(row, rowWord))
            {
                // rectangle is full
                string lastColumnWord = wordsRectangle.GetLastColumnWord();
                if (columnWords.Contains(lastColumnWord))
                {
                    wordsRectangle.FillColumn(column, lastColumnWord);
                }

                return;
            }

            var columnPrefix = wordsRectangle.GetColumnPrefix(column.Index);

            foreach (string columnWord in columnWords.StartsWith(columnPrefix))
            {
                FillColumnInRectangle(wordsRectangle,
                                      new WordsMatrix.Location(row), new WordsMatrix.Location(column), rowWords, columnWords, columnWord);
            }
        }
Exemple #2
0
        void FillColumnInRectangle(WordsMatrix wordsRectangle, WordsMatrix.Location row, WordsMatrix.Location column,
                                   Trie rowWords, Trie columnWords, string columnWord)
        {
            if (wordsRectangle.IsFull)
            {
                return;
            }

            if (wordsRectangle.FillColumn(column, columnWord))
            {
                // Finished columns
                return;
            }

            var rowPrefix = wordsRectangle.GetRowPrefix(row.Index);

            foreach (string rowWord in rowWords.StartsWith(wordsRectangle.GetRowPrefix(row.Index)))
            {
                FillRowInRectangle(wordsRectangle,
                                   new WordsMatrix.Location(row), new WordsMatrix.Location(column), rowWords, columnWords, rowWord);
            }
        }