develooper Front page | perl.golf | Postings from July 2002

Re: more minigolf

Thread Previous | Thread Next
From:
Chris Dolan
Date:
July 11, 2002 07:49
Subject:
Re: more minigolf
Message ID:
3D2D9A30.8040301@clotho.com
Add your solutions to this list

---- Zero-based ----

45 Chris Dolan
-l s/\d+/$&+$'/eg,s/^/1 /for($_=1)x+pop;print

49 Chris Dolan (non-regex)
map$x/=@_=(1,map$_+$_[++$x],@_),0..pop;print"@_
"

81 Chris Dolan (factorials)
@_=map{$t=$n;$a=1;$a*=$t--/($n-$t)while$t>$_&&$n-$t<$_;$a}0..($n=pop);print"@_
"

---- One-based ----

48  Jasper McCrea
-l s/\S+/$&+$'/eg&s/^/1 /for($_)x pop;chop;print

49 Chris Dolan
-l s/\d+/$&+$'/eg,s/^/1 /for($_=1)x(-1+pop);print

49 Chris Dolan
map$x/=@_=(1,map$_+$_[++$x],@_),1..pop;print"@_
"


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About