Ejemplo n.º 1
0
        public WordChainList Solve(Word word)
        {
            WordChainList firstState = new WordChainList(WordList);

            firstState.Add(word);
            WordChainList ans = firstState;

            _queue.Enqueue(firstState);
            while (_queue.Count > 0)
            {
                WordChainList curr = _queue.Dequeue();
                ans = curr;
                foreach (Word w in Candidate(curr.LastWord))
                {
                    if (ans.Find(x => x == w) != null)
                    {
                        continue;
                    }

                    curr.Add(w);
                    _queue.Enqueue(curr.Clone());
                    curr.RemoveAt(curr.GetCount() - 1);
                }
            }
            return(ans);
        }
Ejemplo n.º 2
0
        public WordChainList Clone()
        {
            WordChainList wcl = new WordChainList(AllWords)
            {
                _chain = _chain.ToList()
            };

            return(wcl);
        }