Exemplo n.º 1
0
        public static uint CountRevealedWords(this CrosswordContent content, IEnumerable <char> givenCharacters)
        {
            SortedSet <char> sortedGivenChars = new SortedSet <char>(givenCharacters);
            uint             count            = 0;

            foreach (string word in content.WordList)
            {
                bool wordRevealed = true;
                foreach (char c in word)
                {
                    if (!sortedGivenChars.Contains(c))
                    {
                        wordRevealed = false;
                        break;
                    }
                }

                if (wordRevealed)
                {
                    ++count;
                }
            }

            return(count);
        }
Exemplo n.º 2
0
        public static uint CountExcludedWords(this CrosswordContent crossword, IEnumerable <char> excludedCharacters)
        {
            SortedSet <char> sortedExcludedChars = new SortedSet <char>(excludedCharacters);
            uint             count = 0;

            foreach (string word in crossword.WordList)
            {
                foreach (char c in word)
                {
                    if (sortedExcludedChars.Contains(c))
                    {
                        ++count;
                        break;
                    }
                }
            }

            return(count);
        }
Exemplo n.º 3
0
        public LotteryTicket(
            uint numberOfGivenCharacters,
            CrosswordContent crossword,
            SortedDictionary <uint, double> prizeTable)
        {
            if (numberOfGivenCharacters > (uint)Constants.Alphabet.Length)
            {
                throw new ArgumentException("The number of given characters cannot exceed the alphabet size.");
            }
            if (crossword == null)
            {
                throw new ArgumentNullException("crossword");
            }
            if (prizeTable == null)
            {
                throw new ArgumentNullException("prizeTable");
            }

            NumberOfGivenCharacters = numberOfGivenCharacters;
            Crossword  = crossword;
            PrizeTable = prizeTable;
        }