4

I need to find, for $n = 0, 1, . . . , 52$, the number of distinguishable subsets of size n. Blackjack deck has $4$ cards for each value from $1$ to $9$ and $16$ cards of value $10$, color doesn't matter.

I know that the total number of combinations is $5^9*17$, but when I'm trying to find subsets they don't reach that, there's always more or less. Until $n=5$ it's trivial.

Then, until $n=16$ I'm calculating number of combinations of max $4$ cards of each value and adding combinations with more than $4$ $10$s, e.g. for $n=8$ I have $22110$ combinations of max $4$ cards of each value $+ 220$ combinations for 10,10,10,10,10,x,x,x, which gives $22330$.

Then, for $n = (17,...,26)$ I'm using similar strategy. E.g. for $n=18$ I have $780175$ combinations with max $4$ cards of each value $+ 264220$ combinations for 10,10,10,10,10,x,x,x,x,x,x,x,x,x,x,x,x,x (where in place of x I can still put only $4$ $10$s) $+22110$ combinations for 10,10,10,10,10,10,10,10,10,10,x,x,x,x,x,x,x,x $+210$ combinations for 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,x,x,x (where in place of x I can put only $1$ $10$) $=1066715$.

I did it also with the same strategy, but when adding assuming there's no limit for $10$s, then subtracting combinations with more than $16$ $10$s - I got the same result $(780175+286550-10=1066715)$.

For bigger $n$s I used recursive logic - e.g. for $n=50$ I can only choose $2$ cards, so it's $55$ again, as for $n=2$, so it goes.

With this method I'm missing 1287 counts. What am I doing wrong?

RobPratt
  • 45,619
Monia
  • 51
  • 1
    What does "distinguishable" mean here? Are you assuming that Aces are always chosen to have value $1$? – lulu Dec 21 '23 at 14:43
  • Just to organize the computation, I'd try to do it for the non-$10's$ first. Call that number $a_n$. It's then easy to get the desired count as a sum of those values. – lulu Dec 21 '23 at 14:51
  • Distinguishable means, that, e.g. {1,2} and {2,1} count as 1 - order doesn't matter. Values per se are not important in this problem, as we are not summing them in any way. We can denote it as 1 (as I did), as 11 or as A. Just what's easier and clearer. – Monia Dec 21 '23 at 14:55
  • Ok, so then my proposed organizing principle should work. Doesn't seem that bad to count the $a_n's$....of course, the general problem of Stars and Bars with caps has known algorithmic approaches, though it lacks a convenient closed form. Implementing those is one way to go, though with small numbers, as here, improvised methods shouild be fine. – lulu Dec 21 '23 at 15:15
  • 1
    It's essentially a massive PIE with $a+b+c + ... + k = n$ and $a, b, ... , i \in [0, 5]$, $k \in [0, 17]$. – Calvin Lin Dec 21 '23 at 15:54

2 Answers2

2

If you don’t want to think about it too much, the ordinary generating function is the way to go. In your case, the coefficient of $x^n$ in $$ f(x)=(1+x+x^2+x^3+x^4)^9 \cdot (1+x+\ldots+x^{15}+x^{16}) $$ is your answer. Equivalently, $$ f(x)=\frac{(x^5-1)^9 (x^{17}-1)}{(x-1)^{10}}. $$ As a bonus, it’s clear (from the first form) that the sum of all the coefficients is $f(1)=5^9\cdot 17$, which is your checksum.

mjqxxxx
  • 41,358
1

I found the missing counts. For $n=22$ we have $780175$ (max 4 of each card) $+ 886399$ (combinations for $n=17$) $-1992$ (instead of $-1993$) $= 1664582$ (instead of $1664581$)

From $n=23$ I needed to subtract $1905$ (instead of $-1915$), and so on, until $n=26$. It was the calculation error, the method itself works, if someone will need it in the future.

PIE with $a+b+c+...+j=n$ and $a,b,...,i∈[0,4], j∈[0,16]$ also works perfectly, repeating the result.

Monia
  • 51