Need help figuring out possible combinations in card game I am creating

128 Views Asked by At

I am not sure if this is the right place to be asking the question, but hoping for some help. I created a simple card game for a D&D game I am running and I am trying to assign strength to each hand, I wanted to do this by knowing the possible combinations of each hand.

In this game, there is a deck of 45 cards, 5 suits each suit has cards value 1-9. Player has 5 cards in his hand, and the goal is to get cards in hand to equal a multiple of 5, i.e 5,10,15...,45. So I wanted to know how many possible ways are there for a player to get a hand equal to each of those multiples using the cards available in the deck? e.g. to get to a sum of 5 there is only 1 possible hand, you must have all 1's. However I do not know how to easily compute this for the values with many more combinations. Any help would be appreciated!

Thank you!

3

There are 3 best solutions below

0
On BEST ANSWER

What you're looking for are partitions of the totals (but see the Note below). Mathematica has a convenient function for enumerating these: IntegerPartitions[]; specifically, using IntegerPartitions[n,{5},{1,2,3,4,5,6,7,8,9}] gives the partitions of $n$ into $5$ summands taken from the values $1$ to $9$.

The results are below. Note that $n$ and $(50-n)$ have the same number of partitions ($p$). I'll list the ones for the smaller number; to get the larger number, replace each entry by $10-n$. (So, partition $\{1,1,1,1,1\}$ for $5$ corresponds to partition $\{9,9,9,9,9\}$ for $45$.)

Note: These listed hands, and the values $p$, don't account for suit. If you consider the hand $\{6,1,1,1,1\}$ with a "Suit X" $6$ distinct from one with a "Suit Y" $6$, then there's more work to do. Nevertheless, it could be helpful to see what numbers are involved to get each total.

$$\begin{array}{ccl} n & p & \\ \hline 5, 45 & 1 & \{1, 1, 1, 1, 1\} \\ \hline 10, 40 & 7 & \{6, 1, 1, 1, 1\}, \{5, 2, 1, 1, 1\}, \{4, 3, 1, 1, 1\}, \{4, 2, 2, 1, 1\}, \\ &&\{3, 3, 2, 1, 1\}, \{3, 2, 2, 2, 1\}, \{2, 2, 2, 2, 2\} \\ \hline 15, 35 & 28 & \{9, 3, 1, 1, 1\}, \{9, 2, 2, 1, 1\}, \{8, 4, 1, 1, 1\}, \{8, 3, 2, 1, 1\}, \\ && \{8, 2, 2, 2, 1\}, \{7, 5, 1, 1, 1\}, \{7, 4, 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4, 3\}, \{9, 4, 4, 4, 4\}, \{8, 8, 7, 1, 1\}, \ \\ &&\{8, 8, 6, 2, 1\}, \{8, 8, 5, 3, 1\}, \{8, 8, 5, 2, 2\}, \{8, 8, 4, 4, 1\}, \ \\ &&\{8, 8, 4, 3, 2\}, \{8, 8, 3, 3, 3\}, \{8, 7, 7, 2, 1\}, \{8, 7, 6, 3, 1\}, \ \\ &&\{8, 7, 6, 2, 2\}, \{8, 7, 5, 4, 1\}, \{8, 7, 5, 3, 2\}, \{8, 7, 4, 4, 2\}, \ \\ &&\{8, 7, 4, 3, 3\}, \{8, 6, 6, 4, 1\}, \{8, 6, 6, 3, 2\}, \{8, 6, 5, 5, 1\}, \ \\ &&\{8, 6, 5, 4, 2\}, \{8, 6, 5, 3, 3\}, \{8, 6, 4, 4, 3\}, \{8, 5, 5, 5, 2\}, \ \\ &&\{8, 5, 5, 4, 3\}, \{8, 5, 4, 4, 4\}, \{7, 7, 7, 3, 1\}, \{7, 7, 7, 2, 2\}, \ \\ &&\{7, 7, 6, 4, 1\}, \{7, 7, 6, 3, 2\}, \{7, 7, 5, 5, 1\}, \{7, 7, 5, 4, 2\}, \ \\ &&\{7, 7, 5, 3, 3\}, \{7, 7, 4, 4, 3\}, \{7, 6, 6, 5, 1\}, \{7, 6, 6, 4, 2\}, \ \\ &&\{7, 6, 6, 3, 3\}, \{7, 6, 5, 5, 2\}, \{7, 6, 5, 4, 3\}, \{7, 6, 4, 4, 4\}, \ \\ &&\{7, 5, 5, 5, 3\}, \{7, 5, 5, 4, 4\}, \{6, 6, 6, 6, 1\}, \{6, 6, 6, 5, 2\}, \ \\ &&\{6, 6, 6, 4, 3\}, \{6, 6, 5, 5, 3\}, \{6, 6, 5, 4, 4\}, \{6, 5, 5, 5, 4\}, \ \\ &&\{5, 5, 5, 5, 5\} \end{array}$$

4
On

The number of ways to make a total of $t$ is the coefficient of $x^t$ in $$(x+x^2+\cdots+x^9)^5$$ Each factor represents one of the cards and the term within that factor represents the card. Since we multiply the terms by adding exponents, the claim follows.

Now, we can just ask Wolfram Alpha to multiply it out. You just have to pick out the coefficients of terms of interesting degree. For example, there are $976$ ways to make a total of $35$.

1
On

Neither answer so far has successfully gotten to the probabilities of certain hand totals as having occurred and are unfairly biased towards hands which can only exist with large numbers of suits and against hands which can occur with many or few suits.

Writing a quick and dirty javascript can give the actual totals:

totalHands = function(target){
count=0;
for(a=1; a<46; a++){for(b=a+1;b<46;b++){for(c=b+1;c<46;c++){for(d=c+1;d<46;d++){for(e=d+1;e<46;e++){if((a-1)%9+(b-1)%9+(c-1)%9+(d-1)%9+(e-1)%9+5 == target){count++;}}}}}}
console.log(count)}

This counts the total number of hands (suits relevant and order irrelevant) for your desired sums. Dividing by $\binom{45}{5}$ gives the probability of having gotten said sum.

The multiples of five in particular occur with the following frequencies and probabilities:

$$\begin{array}{c|c|c}\text{Sum}&\text{Frequency}&\text{Probability}\\\hline 5&1&\approx 8.2\times 10^{-7}\\10&1776&\approx 0.00145\\15&18251&\approx 0.0149\\20&59226&\approx 0.0485\\25&85751&\approx 0.07019\end{array}$$

The probabilities are symmetric with respect to $25$, so the probability of hitting a sum of $20$ is the same as hitting a sum of $30$ for instance and so on...