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!
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, usingIntegerPartitions[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, 2, 1, 1\}, \{7, 3, 3, 1, 1\}, \\ && \{7, 3, 2, 2, 1\}, \{7,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