Perl Quiz-of-the-Week #6
Mark Jason Dominus <[email protected]> Wed, 20 Nov 2002 17:31:26 -0500
| Newsgroups | gmane.comp.lang.perl.qotw.quiz-of-the-week |
|---|---|
| Organization | Plover Systems |
| Message-ID | <[email protected]> |
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 enviéis soluciones, pistas, o cualquier otra
cosa que pueda echar a perder la resolución del problema hasta
que hayan pasado por lo menos 60 horas desde el envío de este
mensaje. Gracias.
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.
WICHTIG: Bitte schicken Sie keine Lösungen, Tipps oder Hinweise für
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.)