Thread QOTW 23 'perl' quiz (13 answers)
Opened by Crian at 2004-09-02 11:38

Crian
 2004-09-02 11:38
#49823 #49823
User since
2003-08-04
5873 Artikel
ModeratorIn
[Homepage]
user image
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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.


Bitte auch hier vor Ablauf der 60 Stunden keine Hinweise oder Lösungen posten.

Datumstempel der Mail war: Wed, 01 Sep 2004 12:50:14 -0400
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite

View full thread QOTW 23 'perl' quiz