On 15/11/2007, Phil Carmody <[EMAIL PROTECTED]> wrote: > I saw this on sci.math, and thought "one liner" ;-) > I even think a DP non-recursive approach should be quite quick. > Keeping the output in the logical order might cost a few strokes.
First pass:
sub f {
my($i,$c,@p)[EMAIL PROTECTED];
$i?
map{f($i-1,$c+/\(/-/\)/,@p,$_)}!$c?'(':$c-$i?qw{) (}:')':
print join'',@p
}
f($ARGV[0]*2);
I suppose that will give an undef for 0...
--
Jasper
