Ejemplo n.º 1
0
        /// <summary>
        /// Rozhoduje, zda je dané slovo složeno z předaných písmen
        /// </summary>
        /// <param name="word"></param>
        /// <returns></returns>
        public bool MatchLetters(LettersCount testWord)
        {
            foreach (var pair in lettersCount)
            {
                if (!(testWord.ContainsLetter(pair.Key) && testWord[pair.Key] == pair.Value))
                    return false;
            }

            return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Vrátí slova, která lze poskládat v některém řádku
        /// </summary>
        /// <param name="lettersCount"></param>
        /// <param name="rows"></param>
        /// <returns></returns>
        private Dictionary<string, int> GetPassedRows(string[] wordSameLength, string[] rows)
        {
            Dictionary<string, int> passedRows = new Dictionary<string, int>();
            Dictionary<string, LettersCount> lettersCount = new Dictionary<string, LettersCount>();
            wordSameLength.ForEach(x => lettersCount[x] = new LettersCount(x));

            LettersCount[] rowsLetterCount = new LettersCount[rows.Length];
            rows.Length.Times(i => rowsLetterCount[i] = new LettersCount(rows[i]));

            for (int i = 0; i < rows.Length; i++)
            {
                foreach (var word in lettersCount)
                {
                    if (word.Value.MatchLetters(rowsLetterCount[i]))
                    {
                        passedRows[word.Key] = i;
                        break;
                    }
                }
            }

            return passedRows;
        }