Correctly stating a stars and bars problem I am new to this site and I wish to combine 4 digits (0-9) to sum to a total of  21. How many combinations would achieve this result? 
Using a stars and bars approach to the problem I cannot  get to the total of 592 combinations which is the apparent correct answer. 
Can anyone help?
 A: To get the constraints accounted for, you need to use inclusion-exclusion. In this case, we can simplify slightly by considering the digit sum to $15$, which will have the same number of options as the digit sum to $21$ as each digit can be transformed with $d_i'=9-d_i$.
So we start with the unconstrained stars and bars, $\binom{15+3}3$, then subtract off the stars-and-bars results when each digit has broken the constraint of maximum $9$ by "preloading" $9+1$ to that digit, giving $15-10$ remaining to allocate so  $\binom{5+3}3$ options per choice of overloaded digit. This gives:
$$\binom{15+3}3 - \binom 41 \binom{5+3}3= 816 - 4\cdot 56 = 592$$
If we went the route of directly finding the digit sum to $21$, we would need to also account for cases where two digits had broken the maximum constraint in order to correct for double-subtraction. This would be:
$$\binom{21+3}3 - \binom 41 \binom{11+3}3 + \binom 42\binom {1+3}3 = 2024- 4\cdot 364 + 6\cdot 4 = 592$$
A: The method of inclusion-exclusion parallels the generating function method but I feel is a little more straightforward.
With stars and bars we have 21 stars and 3 bars separating 4 bins.
Let $A_k$ ($k=1,2,3,4$) be the set of solution vectors $(x_1,x_2,x_3,x_4)$ to 
$$x_1+x_2+x_3+x_4=21$$ 
(for $x_k\in\mathbb{N}\cup\{0\}$) such that $x_k\ge 10$.
Firstly there are
$$\binom{21+3}{3}=\binom{24}{3}$$
total unrestricted solution vectors and we have
$$|A_k|=\binom{21+3-10}{3}=\binom{14}{3}$$
because we place $10$ stars in bin $k$ then there are $21-10=11$ remaining stars to arrange with $3$ bars. Then
$$|A_{k_1}\cap A_{k_2}|=\binom{21+3-20}{3}=\binom{4}{3}$$
because two of the $4$ bins have $10$ stars each so there is $21-20=1$ star remaining to arrange with $3$ bars. All higher order intersections are empty because we cannot place $10$ stars in each of $3$ bins.
Inclusion-exclusion says that our desired count is
$$|(A_1\cup A_2\cup A_3\cup A_4)'|=S_0-S_1+S_2$$
where
$$S_r=\sum_{k_1\le k_2\le\cdots \le k_r}|A_{k_1}\cap A_{k_2}\cap \ldots \cap A_{k_r}| =\binom{4}{r}\binom{21+3-10r}{3}$$
and therefore
$$\begin{align}|(A_1\cup A_2\cup A_3\cup A_4)'|&=S_0-S_1+S_2\\
&=\binom{4}{0}\binom{24}{3}-\binom{4}{1}\binom{14}{3}+\binom{4}{2}\binom{4}{3}\\
&=592
\tag{Answer}\end{align}$$
