Size: 1766
Comment:
|
Size: 1680
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
= Assignment 2: Word Ladder = | = Assignment 2: Ordered Word Ladders = |
Line 7: | Line 7: |
A ''word ladder'' is a sequence of words * which are in alphabetic order * each word in the sequence differs from its predecessor by * changing one letter, e.g. ''born→barn'' * adding or removing one letter, e.g. ''band→brand'' |
An ''ordered word ladder'' is an alphabetically-ordered sequence of words where each word in the sequence differs from its predecessor by: * changing one letter, e.g. ''barn→born'' * adding or removing one letter, e.g. ''band→brand'' |
Line 13: | Line 11: |
The following are examples of word ladders of different length (that could each easily be made longer): * ''big→bit→bat→boat'', length 4 * ''cold→cord→word→ward→warm'', length 5 * ''line→fine→five→dive→live→like→lake→take→bake→cake→came→fame'', length 12 |
The following are examples of word ladders of different length: * ''ban→bar→boar→boat→goat'', length 5 * ''cab→can→cane→dane→date→mate→mite→site→size'', length 9 |
Line 18: | Line 15: |
/* | |
Line 19: | Line 17: |
Your assignment is to write a program that computes the longest word chain(s) that can be built from a set of words given on stdin. The output of your program is the maximum length of all the word chains that can be built from the input words, together with all the word chains that have this length. | Your assignment is to write a program that computes the longest word ladder(s) that can be built from a set of words given on stdin. The output of your program is the maximum length ordered word ladder, together with all the ordered word ladders that have this length. |
Line 29: | Line 27: |
* there is no punctuation or digits in the input | |
Line 33: | Line 32: |
* Call your source program ''ladder.c'' (for submission purposes). * In ''ladder.c'' include the statement |
* Call your source program ''ladders.c'' (for submission purposes). * In ''ladders.c'' include the statement |
Line 39: | Line 38: |
*/ |
Contents
Assignment 2: Ordered Word Ladders
An ordered word ladder is an alphabetically-ordered sequence of words where each word in the sequence differs from its predecessor by:
changing one letter, e.g. barn→born
adding or removing one letter, e.g. band→brand
The following are examples of word ladders of different length:
ban→bar→boar→boat→goat, length 5
cab→can→cane→dane→date→mate→mite→site→size, length 9