No such thing as a small change  
PerlMonks 
Golf: Selection from sets (Choose)by knobunc (Pilgrim) 
on May 24, 2001 at 21:30 UTC ( #83013=perlmeditation: print w/replies, xml )  Need Help?? 
Since there was just a golf for factorials, I figured that doing one for the number of ways to select M objects from a set of N objects without repetition might be appropriate. Basically, if I have a set of 4 cards, how many ways can I select a hand of 1 card from the set without repeating myself? The answer is obviously 4. Now if I have a hand size of 2 how many ways are there? The answer is 6, but it is less obvious. The general solution is defined by the function: Where M is the size of the set and N is the number of cards to select. And M! is the factorial of M. See Golf: Factorials for more info. The following are test cases that you can use:
The interface for the resulting code should be:
If you want to define a factorial subroutine that should be included in the size of the code. ben
Back to
Meditations

