Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (15)
As of 2014-08-27 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (253 votes), past polls