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

Home > Algorithms
Word Ladder Construction (Posted on 2004-01-15) Difficulty: 3 of 5
Write an algorithm to create word ladders such as any of the following:
hard bard bird bind bins
hard ward word wood wool
hard herd head dead dean
hard hand band bind bins
hard harp hasp wasp wisp

where a word is given which must be transformed into some other word (not specified in advance) with the same number of letters, but each letter position changed from its original value, in as many steps as there are letters in the word, each step also being a valid word. This is similar to the various Word Meld puzzles on this site, except there are as many steps as there are letters in the word and each letter is changed, with each letter position being changed exactly once.

Input consists of the starting word only. It is assumed that the number of steps will be the same as the number of letters in the word. 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. The program will find all the eligible word ladders given the words in the list.

The program will, of course, terminate without finding any results if in fact a word ladder cannot be constructed starting with the input word.

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

Comments: ( Back to comment list | You must be logged in to post comments.)
can someone review this | Comment 2 of 7 |
1.Start

2.Replace first letter with an alphabet A-Z excluding itself and any other alphabets already used. Check if the new word is in words.txt
3.NO for 2, goto 5
4.YES for 2, goto 8.

5.Check if all possible alphabets are used up replacing the first letter.
6.NO for 5, goto 2.
7.YES for 5, QUIT.

8.Replace the next letter with an alphabet A-Z excluding itself and any other alphabets already used. Check if the new word is in words.txt
9.NO for 8, goto 11.
10.YES for 8, goto

11.Check if all possible alphabets are used up.
12.NO for 11, goto 14.
13.YES for 11,QUIT.

14.Replace the letter again with an alphabet A-Z excluding itself and any other alphabets already used.Check if the new word is in words.txt
15.NO for 14, goto 11.
16.YES for 14, goto 17.

17.Check if any more letters are in the original word.
18.NO for 17 DONE.
19.YES for 17, goto 8.

  Posted by Surender Taalla on 2004-01-15 17:31:19
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 (3)
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