Skip to content

wordChain takes in two words of equal length, and returns a sequence of words, going from the first to the second, changing only one letter at a time, where each word is found in a dictionary.

Notifications You must be signed in to change notification settings

elias6/wordChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

wordChain

wordChain takes in two words of equal length, and returns a sequence of words, going from the first to the second, changing only one letter at a time, where each word is found in a dictionary.

Example: ./wordChain.py frog goat will produce this output: ['frog', 'grog', 'grot', 'grat', 'goat']

This problem was in the book "Cracking the Coding Interview, 5th Edition" (problem 18.10, page 476) by Gayle Laakmann McDowell. My solution pre-processes the dictionary to create a graph. This takes up some hard drive space, and it takes some time the first time the program is run, but subsequent searches are very fast. Unlike the solution in the book, mine works for all words, even if they contain non-English letters.

About

wordChain takes in two words of equal length, and returns a sequence of words, going from the first to the second, changing only one letter at a time, where each word is found in a dictionary.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages