Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Golf: Selection from sets (Choose)

by jynx (Priest)
on May 25, 2001 at 01:11 UTC ( #83136=note: print w/replies, xml ) Need Help??


in reply to Golf: Selection from sets (Choose)


i'm posting this just to show some different code. The methodolgy doesn't use factorials per se, just lists of numbers. There are probably some ways to optimize, but i don't have enough time to really try right now.
sub c{ my($c,$d)=@_;my%n=map{$_=>1}1..$c;delete$n{$_}for 1..($c-$d); eval join'/',map"($_)",(join'*',keys%n),(join'*',1..$d) }
It's warnings and strict compliant, and returns all the right answers.

nuf evah,
jynx

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://83136]
help
Chatterbox?
[LanX]: he was "meating" Italian monks oO?
[erix]: then again, there are people who do 10 full triathlons on 10 consecutive days, so it must be doable
choroba's friend has done the Pacific Crest Trail, it's 4200 km
LanX Ladies and gentlemen: due to shortages of "Body of Christ" we have to resort to Body of Monks ...
LanX ... buon appetito!
[LanX]: Pacific Crest Trail is really hard stuff
[Eily]: erix he plans to go as far as leuca

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-12-13 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?