perlmeditation
knobunc
<p>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.</p>
<p>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.</p>
<p>The general solution is defined by the function:
<code>
Choose(M, N) = M!
----------------
N! * (M - N)!
</code>
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.</p>
<p>The following are test cases that you can use:<br>
<table border=1>
<tr><th>M</th><th>N</th><th>Answer</th><th>Notes</th></tr>
<tr><td>52</td><td>5</td><td>2598960</td><td>Number of 5 card hands in a deck of 52 cards</td></tr>
<tr><td>52</td><td>7</td><td>133784560</td><td>Number of 7 card hands in a deck of 52 cards</td></tr>
<tr><td>52</td><td>13</td><td>635013559600</td><td>Number of 7 card hands in a deck of 52 cards
</td></tr>
<tr><td>52</td><td>52</td><td>1</td><td>Number of ways to select a hand size of 1 from a 52 card deck</td></tr>
</table>
<p>
<p>The interface for the resulting code should be:
<code>
print c($m, $n);
</code><br>
If you want to define a factorial subroutine that should be included in the size of the code.
</p>
<p>-ben</p>