Re: Just chipping in...
Jasper <[email protected]> Thu, 15 Nov 2007 14:50:01 +0000
| Newsgroups | gmane.comp.lang.perl.golf |
|---|---|
| Message-ID | <[email protected]> |
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)=@_; $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