[Neworleans-pm] Fwd: Perl Quiz of the Week #26 (Acrostic puzzle formatter)

E. Strade, B.D. estrabd at yahoo.com
Thu Oct 14 18:02:13 CDT 2004




=====
http://www.brettsbsd.net/~estrabd

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

----- Original message -----
From: "Mark Jason Dominus" <mjd at plover.com>
To: perl-qotw at plover.com
Date: Thu, 14 Oct 2004 16:49:48 -0400
Subject: Perl Quiz of the Week #26 (Acrostic puzzle formatter)


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 plaît, attendez au minimum 60 heures après la
        date de ce message avant de poster solutions, indices ou autres
        révélations. Merci.

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

VNIMANIE: Pozhalujsta ne shlite reshenija, nameki na reshenija, i
        voobshe lyubye podskazki v techenie po krajnej mere 60 chasov
        ot daty etogo soobshenija.  Spasibo.

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

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

Last week I asked folks to write a program to generate acrostic
puzzles, given a quotation and a source credit.  (See

        http://perl.plover.com/qotw/e/025

for complete details.)  Here's an example puzzle:

        ___ ___ ___     ___ ___ ___ ___ ___ ___ ___ ___     ___ ___
        1G  2A  3C      4A  5B  6F  7C  8G  9E  10D 11G     12B 13E


        ___ ___ ___ ___ ___     ___ ___ ___ ___ ___ ___     ___ ___ ___
        14D 15G 16F 17E 18B     19B 20E 21D 22F 23A 24G     25C 26F 27G


        ___ ___ ___ ___     ___ ___ ___ ___     ___ ___     ___ ___ ___ 
        28A 29F 30B 31G     32A 33G 34E 35D     36C 37B     38A 39D 40C




        A. ___ ___ ___ ___ ___ ___              Fly headlong
           2   4   38  28  32  23

        B. ___ ___ ___ ___ ___ ___              Where the sun comes up
           19  18  12  30  5   37

        C. ___ ___ ___ ___ ___                  Relinquish
           40  25  36  7   3

        D. ___ ___ ___ ___ ___                  Valuable property
           39  10  21  35  14

        E. ___ ___ ___ ___ ___                  Dangerous
           9   17  13  34  20

        F. ___ ___ ___ ___ ___                  Formerly yours
           22  29  6   26  16

        G. ___ ___ ___ ___ ___ ___ ___ ___      Why you're like your dad
           15  8   24  11  27  33  1   31


There are two parts.  The top part is a quotation; the bottom part is
a list of clues and answer words.  To solve the puzzle, you guess an
answer word based on the clue and fill in its letters.  You then
transfer each letter to the corrspondingly-numbered space in the
quotation.  This may give you enough information to guess one of the
words in the quotation; you can then transfer letters from the
quotation back to the correspondingly-numbered spaces in the answer
words.  (For example, suppose you guess that the second word in the
quotation is "BRAISING".  Then you put an "R" into space 5B, and also
into space 5 of answer word B in the bottom section.)


The goal is to find the entire quotation.  This type of puzzle is
called an "acrostic" puzzle because the initial letters of the answer
words spell the name of the author of the quotation, or the title of
the source.

Actually the puzzle is above not exactly the example I posted last
week, because the example I posted contained several errors.  I later
posted a correction, which *also* contained several errors.  Ouch!

Although it is straightforward in principle to take a quotation and an
appropriate list of answer words and to construct the puzzle, it
turned out to be a lot trickier to actually do this than I thought it
would be.  I kept getting the letters confused.  I also inserted
several typos.  Clearly, this is a task that is well-suited for a
computer.

This week, you'll write a program to format and print puzzles.  The
input to the program will be a file with two sections.  The first
section will be the quotation, and will be followed by a single blank
line, and then the second section, which will be the list of answer
words, one per line.  A sample input:

        Paul Gray ... has always edited and improved my writings ...
        In return, I never mention his name unless somebody points out
        an error ... in which case I always say, "Paul Gray told me
        that."

        Ravish
        Organdy
        Bastion
        Earthy
        Rescind
        Transit
        Elysian
        Midspan
        Avow
        Company
        Hearty
        Odious
        Limp
        Lignum
        Eastern
        Rumple
        Nowise
        Enough
        Reliant
        Study
        Lawyer
        Atheism
        Wade

Your program will emit an output analogous to the one at the beginning
of this message.  The letters in the quotation should be replaced by
blanks; punctuation should be deleted.  The blanks should be numbered
consecutively, and each blank should be labeled with the corresponding
letter of the answer word in which its letter appears.  The bottom
section of your puzzle should have blanks of the appropriate length
for each answer word, and the blanks should be labeled with the
appropriate numbers.  Each number should appear exactly once in the
upper section and once in the lower section.  Each upper-section space
should have the correct letter.

Your program does not have to generate the clues themselves; those
will be added later by a human.  That is, it only should generate the 

       G. ___ ___ ___ ___ ___ ___ ___ ___      
           15  8   24  11  27  33  1   31

part of the answer section; it does not need to come up with "Why
you're like your dad".

An important quality factor is that the letters of an answer word
should not be clumped together in the quotation; they should be spread
out to appear in many different words in the quotation, and vice
versa.  

If there are more than 26 answer words, it is traditional to label
them "AA", "BB", and so on.

The example quotation above is an abridged version of the following:

        Much of what I write was suggested by Paul Gray, and in all
        cases, he has always edited and improved my writings before
        they are published. In return, I never mention his name unless
        somebody points out an error in one of my publications, in
        which case I always say, "Paul Gray told me that."

                -- Robert E. Machol, "Lerner's Law".
                   _OR/MS Today_, 1998

"Lerner's Law", according to Dr. Machol, is "no good deed goes
unpunished."




More information about the NewOrleans-pm mailing list