using System.Collections.Generic;
public static void Main()
Console.WriteLine("********* First Example *********");
Console.WriteLine("##### Result = {0} #####", LadderLength("hit", "cog", new List<string>{"hot","dot","dog","lot","log","cog"}));
Console.WriteLine("\n\n********* Second Example *********");
Console.WriteLine("##### Result = {0} #####",LadderLength("hit", "cog", new List<string>{"hot","dot","dog","lot","log"}));
static int LadderLength(string beginWord, string endWord, IList<string> wordList) {
var foundSet = new HashSet<string>();
var wordSet = new HashSet<string>(wordList);
while (!foundSet.Contains(endWord))
var toAdd = new HashSet<string>();
foreach(var w in foundSet)
Console.WriteLine("Distance = {0}, word = {1}", distance, w);
for(int i = 0; i < w.Length; i++)
char[] chars = w.ToCharArray();
for(char c = 'a'; c <= 'z'; c++)
string word = new String(chars);
if(wordSet.Contains(word))