Re: Perl Quiz of the Week #23
Leo Cacciari <[email protected]>
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Sep 01, 2004 at 12:50:14PM -0400, Mark Jason Dominus scripsit: > > 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. I have a fairly quick solution based on a 'generation' approach. On a 800MHz Pentium III (admittedly with X grafic interface not running) it takes less than 2 seconds for n = 10, 6 seconds an an half for n = 11, a little more than 24 seconds for n = 12 and less than 1 minute and an half for n = 13. I'll try to run it on a somewhat better machine than my laptop to see how it behaves for higer values of n -- Leo "TheHobbit" Cacciari