Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Golf: Selection from sets (Choose)

by srawls (Friar)
on May 24, 2001 at 22:44 UTC ( #83064=note: print w/ replies, xml ) Need Help??


in reply to Golf: Selection from sets (Choose)

55 chars (see update), not counting the sub subName parts.

sub a{ eval join'*',1..pop } sub f { a($_[0])/(a($_[1])*a($_[0]-$_[1])) }

Update: changed code a bit, down to 53 characters now

The 15 year old, freshman programmer,
Stephen Rawls


Comment on Re: Golf: Selection from sets (Choose)
Download Code
Re (tilly) 1: Golf: Selection from sets (Choose)
by tilly (Archbishop) on May 25, 2001 at 04:30 UTC
    It is usual when counting helper subroutines to count the declaration of the helper in the overall length. So your code is of length 60.

    Incidentally here is another reasonably efficient one to compute of length 53. Mainly interesting because it works on a different principle.

    sub c{ my@c=1;map$c[$_]+=$c[$_-1],1..$_[1]for 1..$_[0];pop@c }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2014-10-31 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (214 votes), past polls