Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Golf: Selection from sets (Choose)

by no_slogan (Deacon)
on May 25, 2001 at 00:42 UTC ( #83129=note: print w/ replies, xml ) Need Help??


in reply to Golf: Selection from sets (Choose)

46 characters, passes strict and -w. I wouldn't suggest running it with that sample data without Memoize, unless you have a lot of time to kill.

sub c{ my($m,$n)=@_;$n?$m?c($m-1,$n)+c($m-1,$n-1):0:1 }

Update: We can squeeze a couple more characters out of that...

sub c{ my($m,$n)=@_;$n?$m--?c($m,$n)+c($m,$n-1):0:1 }


Comment on Re: Golf: Selection from sets (Choose)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2015-07-30 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls