All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Word Ladders (Posted on 2003-09-24) Difficulty: 4 of 5
Write an algorithm to solve word ladders such as Word Meld 1 or Word Meld 2. Input consists of the starting and ending words and the maximum number of steps allowed. Available are files containing lists of words of any given length; call one such file, say WORDS5.TXT containing a list of words of 5 letters each, and so on.

See The Solution Submitted by Charlie    
Rating: 3.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Been there, done that | Comment 6 of 11 |
This problem is the interview question for my company. So far we have solutions in a range of languages although my personal favourites are in Perl and Tcl.

The offered solution by SilverKnight employs a depth-first search - which is the most common 'good' answer - but you can speed the search up by doing a double-headed search, ie, start at both the start -and- end words and check for either tree adding a node that already exists in the other search tree.

If you intend to run many word ladder problems against your program, you could always go for a long preperation time (and thereafter a short solution time) by building a graph of words of length N that differ by one character and storing it to disc. That way, all you've got to do is a shortest-path solution over a graph (Dijkstra's Algorithm).
  Posted by Bruce on 2003-09-26 08:42:04
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information