Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Binomial Golf

by japhy (Canon)
on May 30, 2001 at 08:32 UTC ( #84171=note: print w/ replies, xml ) Need Help??

in reply to Binomial Golf

56 chars:

# 123456789_123456789_123456789_123456789_123456789_123456 sub p {$_=pop;@_=(1,map$_[-2]+pop,0..$#_),print"@_\n"while$_>@_}

japhy -- Perl and Regex Hacker

Comment on Re: Binomial Golf
Download Code
Replies are listed 'Best First'.
Re: Re: Binomial Golf
by chipmunk (Parson) on May 30, 2001 at 18:19 UTC
    My best was 59 characters:
    sub p { map{$_[$_]+=$_[$_+1]for 0..$#_;@_=(1,@_);print"@_\n"}1..pop }
    However, I can reduce japhy's solution from 56 to 45 characters:
    sub p { @_=(1,map$_[-2]+pop,@_),print"@_\n"for 1..pop }
    BTW, I find it amusing that monks are giving their golf subroutines one-letter names, when the subroutine name isn't counted in the length of the solution. :)

    I was considering sub pascal's_triangle {} for this one. ;)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://84171]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2015-10-14 03:42 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (320 votes), past polls