DCPM: quiz of the week

Steve Marvell steve at fysh.org
Thu Nov 21 07:50:32 CST 2002


Here is the present quiz of the week for perl. If you like this kind
of thing, get on the list_s_.

Steve

----- Forwarded message from Mark Jason Dominus <mjd at plover.com> -----

Reply-To: perl-qotw-discuss at plover.com
Delivered-To: mailing list perl-qotw at plover.com
Delivered-To: moderator for perl-qotw at plover.com
To: perl-qotw at plover.com
Subject: Perl Quiz-of-the-Week #6
Date: Wed, 20 Nov 2002 17:31:26 -0500
From: Mark Jason Dominus <mjd at plover.com>


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

IMPORTANTE: Por favor, no enviis soluciones, pistas, o cualquier otra
        cosa que pueda echar a perder la resolucin del problema hasta
        que hayan pasado por lo menos 60 horas desde el envo de este
        mensaje. Gracias.

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.

WICHTIG: Bitte schicken Sie keine Lsungen, Tipps oder Hinweise fr
        diese Aufgabe vor Ablauf von 60 Stunden nach dem Datum dieser
        Mail. Danke.

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 function, format_number_list, whose argument is a list of
integers.  It then returns a string which represents the input list in
compact, human-readable form.

For example,

         format_number_list(1, 2, 4, 5, 6, 7, 9, 13, 24, 25, 26, 27)

will return

        "1-2, 4-7, 9, 13, 24-27"

Also write a function, 'expand_number_list', which does the conversion
in the opposite direction, so that

        expand_number_list("1-2, 4-7, 9, 13, 24-27")

will return

        (1, 2, 4, 5, 6, 7, 9, 13, 24, 25, 26, 27)


(Thanks to Mark Hickman for suggesting this quiz problem.)



----- End forwarded message -----
----- Forwarded message from Mark Jason Dominus <mjd at plover.com> -----

Reply-To: perl-qotw-discuss at plover.com
Delivered-To: mailing list perl-qotw at plover.com
Delivered-To: moderator for perl-qotw at plover.com
To: perl-qotw at plover.com
Subject: Perl 'Expert' Quiz-of-the-Week #6
Date: Wed, 20 Nov 2002 17:46:49 -0500
From: Mark Jason Dominus <mjd at plover.com>


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

IMPORTANTE: Por favor, no enviis soluciones, pistas, o cualquier otra
        cosa que pueda echar a perder la resolucin del problema hasta
        que hayan pasado por lo menos 60 horas desde el envo de este
        mensaje. Gracias.

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.

WICHTIG: Bitte schicken Sie keine Lsungen, Tipps oder Hinweise fr
        diese Aufgabe vor Ablauf von 60 Stunden nach dem Datum dieser
        Mail. Danke.

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 generic survey or quiz program, "survey".

The program will read a configuration file in this format:

        How old are you?  0-12; 13-19; 20-24; 25-34; 35-44; 45 or older
        What is your favorite color?  red; blue; black; other
        ...

Each question is on a separate line; the question is everything up to
and including the first '?', and the allowed responses to the question
are the following items separated by ';'.  If the last response ends
with ";;" instead of ";", any data following the ";;" is taken to be
configuration options for that question, separated by spaces.  For
example:

    How old are you?  0-12; 13-19; 20-24; 25-34; 35-44; 45 or older;; OPTIONAL
    What is your favorite color?  red; blue; black;; ALLOW_OTHER

It is up to you to decide what options, if any, should be supported.

The program will then prompt the user with the questions, and read and
validte the responses.  When the user has finished answering the
questions, the program should record the responses in a file.

There should be some way to run the program to get it to disgorge a
report about the aggregate survey responses.  The report should
include: The number of people completing the survey; the number
providing each response to each question, and the percentage breakdown
for the responses to each question.

The program could use the terminal as an interface, or it could have a
Tk interface, or could be a CGI program, or whatever you prefer.



----- End forwarded message -----



More information about the Devoncornwall-pm mailing list