[Kc] Perl 'Expert' Quiz-of-the-Week #22

Garrett Goebel garrett at scriptpro.com
Thu Aug 26 07:41:58 CDT 2004


IMPORTANT: Please do not post solutions, hints, or other spoilers
        until at least 60 hours after the date of this message.
        Thanks.

IMPORTANT: S'il vous plat, attendez au minimum 60 heures aprs la
        date de ce message avant de poster solutions, indices ou autres
        rvlations. Merci.

BELANGRIJK: Stuur aub geen oplossingen, hints of andere tips in de
        eerste 60 uur na het verzendingstijdstip van dit
        bericht. Waarvoor dank.

Qing3 Zhu4Yi4: Qing3 Ning2 Deng3Dao4 Jie1Dao4 Ben3 Xin4Xi2 Zhi1Hou4 60
        Xiao3Shi2, Zai4 Fa1Biao3 Jie3Da2, Ti2Shi4, Huo4 Qi2Ta1 Hui4
        Xie4Lou4 Da2An4 De5 Jian4Yi4.  Xie4Xie4.

----------------------------------------------------------------

Write a program, 'wordladder', which gets two arguments, which are words of
the same length, and which constructs and prints a "word ladder" from the
first word to the second word.

A word ladder from word AAA to word BBB is a sequence of dictionary words
such that:

1. the first word in the sequence is word AAA 2. each word in the sequence
after the first differs from the previous
   word in exactly one letter position
3. the last word in the sequence is word BBB

For example, given the two words "love" and "hate", the program might print
the word ladder:

        love
        hove
        have
        hate

Or it might print:

        love
        lave
        have
        hate

It might also print a longer word ladder, such as

        love
        lore
        lobe
        robe
        role
        rose
        lose
        lost
        most
        mosh
        moth
        math
        hath
        hate

If the program is unable to find a word ladder, it should print an
appropriate error message to the standard error, and exit with a failure
status.

The program should also accept an optional third argument, which, if
specified, is the name of a dictionary file which contains the permissible
words.  If the third argument is omitted, the program should use a default
dictionary.

Sample word lists are available from
        http://perl.plover.com/qotw/words/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20040826/5c2ad541/attachment.htm


More information about the kc mailing list