[Kc] Perl Quiz of the Week #23

Garrett Goebel garrett at scriptpro.com
Wed Sep 1 13:21:46 CDT 2004


From: Mark Jason Dominus [mailto:mjd at plover.com] 
Sent: Wednesday, September 01, 2004 11:50 AM
To: perl-qotw at plover.com
Subject: [Retrieved]Perl Quiz of the Week #23



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.

WICHTIG: Bitte schicken Sie keine Lsungen, Tipps oder Hinweise fr
        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 ]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20040901/6afbf9e0/attachment.htm


More information about the kc mailing list