예제 #1
0
        public WordGroup[] CreateWordGroups(Dictionary <string, bool> ht)
        {
            //We need to group all the words in the dictionary

            //Find the max length of the group
            int maxlength = -1;

            foreach (KeyValuePair <string, bool> item in ht)
            {
                if (item.Key.Length > maxlength)
                {
                    maxlength = item.Key.Length;
                }
            }

            WordGroup[] wordgroups = new WordGroup[maxlength];

            //scan the words and put it in the corresponding groups
            foreach (KeyValuePair <string, bool> item in ht)
            {
                int length = item.Key.Length - 1;
                if (wordgroups[length] == null)
                {
                    wordgroups[length] = new WordGroup();
                }

                wordgroups[length].addWord(item.Key);
            }

            return(wordgroups);
        }
예제 #2
0
        public bool IsComplete(int l, int h, WordGroup list)
        {
            //check whether each column is a valide word
            //and height has required h
            if (this.Height == h)
            {
                // check whehter each column for a word in the ht
                for (int col = 0; col < l; col++)
                {
                    string columnword = GetColumnWordByColumnNo(col);
                    if (list.lookup.ContainsKey(columnword) == false)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }