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

Re: more minigolf

Thread Previous | Thread Next
From:
Phil Carmody
Date:
July 11, 2002 10:37
Subject:
Re: more minigolf
Message ID:
20020711173628.99234.qmail@web21109.mail.yahoo.com
I can't believe people manged to work out how to use regexps to solve
this - they looked to complicated for me , so I just went with the
simple recurrence! My 2 entries inserted in numerical order. Note -
the zero-based one did end up shorter than my one-based one, which
counters what I first thought!

Phil


En op 11 juli 2002 sprak Chris Dolan:

Add your solutions to this list

---- Zero-based ----

44 FatPhil (non-regex)
-l print$t=1,map$".($t*=$x--/$_),1..($x=pop)

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"@_
"

34 Eugene van der Pijll (rejected...)
@a^+=(!$_,@a)for 0..pop;print"@a
"

---- One-based ----

46 FatPhil (non-regex)
-l print$t=1,map$".($t*=--$x/$_),1..~-($x=pop)

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"@_
"

36 Eugene van der Pijll (rejected...)
@a^+=(!$a++,@a)for 0..pop;print"@a
"


=====
-- 
"One cannot delete the Web browser from KDE without
losing the ability to manage files on the user's own
hard disk." - Prof. Stuart E Madnick, MIT. 
So called "expert" witness for Microsoft. 2002/05/02

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

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