Comment previewing has arrived!!! Now on to our regularly scheduled problem.
Today we'll be designing a function that takes in two words and determines if it's possible to transform one word in to the other by changing one letter at a time (letters can not be added or removed, only changed). When a letter is changed the new word must also be a valid word. Each letter index can only be changed one time. Here is an example using "power" and "tuned":
power -> tower -> towed -> toned -> tuned
Most Linux distros come with a built in dictionary or you can find one by searching the internet. Here is one I found for English.
Comments:
Kevin - 10 years, 7 months ago
Lots of room for optimization, but it seems to work.
reply permalink
Virat - 10 years, 7 months ago
Good question, it will take something to solve this.
reply permalink
Anonymous - 10 years, 7 months ago
Recursive python solution, unhappy about the O(n) search of words_found and I had to change the max recursion depth
reply permalink
Anonymous - 10 years, 7 months ago
Much happier with it now I've improved it
reply permalink
gulliver - 10 years, 7 months ago
reply permalink
Anonymous - 10 years, 7 months ago
This is Clojure.
reply permalink
samebchase - 10 years, 7 months ago
Common Lisp solution that adds all the words into a graph, adds edges for 1-neighbours. Word ladder is simply a shortest path between the two words.
Output Image of the word ladder
reply permalink