Perl Quiz of the Week #23
Mark Jason Dominus <[email protected]> Wed, 01 Sep 2004 12:50:14 -0400
| 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.
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.
----------------------------------------------------------------
Write a program, 'parens', which gets a command line argument, n',
which is an integer. The program should print all the
properly-balanced strings of parentheses of length 2n. For example,
given the argument '3', the program should print these five lines:
((()))
(()())
(())()
()(())
()()()
in some order. (The order is not important.)
For the argument '1'; the output should be:
()
and for argument '4', the output should be:
(((())))
((()()))
((())())
((()))()
(()(()))
(()()())
(()())()
(())(())
(())()()
()((()))
()(()())
()(())()
()()(())
()()()()
in some order.
[ ADMIN: I'm still hoping someone will step forward to write a report
about expert quiz #22. - MJD ]