Number of positive ($0$ excluded) integral solutions which contains only $1,2,3$ as variable values to the equation $a_1 +a_2 + a_3 + \ldots + a_6 = 12$ are?
My method was this: It's equivalent to finding coefficient of $x^{12}$ in expansion of $(x+x^2 +x^3)^6$, from that I managed to attain the value as $141$, but I saw a method which I don't get how they managed to do it. They wrote this : $${11 \choose 2} - 5{8 \choose 2} + 15{5 \choose 2} - 15{2 \choose 2} = 141$$ cases. It might be related to PIE but I am not getting how. Can anyone elaborate how they are doing it?
As JMoravitz indicated in the comments, the correct expression should be $$\binom{11}{5} - \binom{6}{1}\binom{8}{5} + \binom{6}{2}\binom{5}{5}$$
A particular solution of the equation $$a_1 + a_2 + a_3 + a_4 + a_5 + a_6 = 12 \tag{1}$$ corresponds to placing $6 - 1 = 5$ addition signs in the $12 - 1 = 11$ spaces between successive ones in a row of $12$ ones. For instance, $$1 + 1 1 + 1 1 1 + 1 1 1 1 + 1 + 1$$ corresponds to the solution $x_1 = 1, x_2 = 2, x_3 = 3, x_4 = 4, x_5 = x_6 = 1$. The number of such solutions is $$\binom{12 - 1}{6 - 1} = \binom{11}{5}$$ since we must select which five of the eleven spaces between successive ones in which to place an addition sign.
The number of solutions of the equation $$x_1 + x_2 + x_3 + \cdots + x_k = n$$ in the positive integers is $$\binom{n - 1}{k - 1}$$ since a solution corresponds to placing $k - 1$ addition signs in the $n - 1$ spaces between successive ones in a row of $n$ ones.
We wish to exclude solutions in which at least one of the variables exceeds $3$. There can be at most two such variables since $3 \cdot 4 + 3 \cdot 1 = 15 > 12$.
One variable exceeds $3$: There are six choices for the variable which exceeds $3$. Suppose it is $a_1$. Then $a_1 \geq 4$, so $a_1' = a_1 - 3$ is a positive integer. Substituting $a_1' + 3$ for $a_1$ in equation 1 yields \begin{align*} a_1' + 3 + a_2 + a_3 + a_4 + a_5 + a_6 & = 12\\ a_1' + a_2 + a_3 + a_4 + a_5 + a_6 & = 9 \tag{2} \end{align*} Equation 2 is an equation in the positive integers with $\binom{9 - 1}{6 - 1} = \binom{8}{5}$ solutions. Hence, there are $$\binom{6}{1}\binom{8}{5}$$ cases in which a variable exceeds $3$.
However, if we subtract this amount from the total, we will have subtracted too much. That is because we have subtracted cases in which two variables each exceed $3$ twice, once for each variable we could designate as the one that exceeds $3$. We only want to subtract those cases once, so we must add them to the total.
Two variables each exceed $3$: There are $\binom{6}{2}$ ways to select the two variables which exceed $3$. Suppose they are $a_1$ and $a_2$. Then $a_1' = a_1 - 3$ and $a_2' = a_2 - 3$ are positive integers. Substituting $a_1' + 3$ for $a_1$ and $a_2' + 3$ for $a_2$ in equation 1 yields \begin{align*} a_1' + 3 + a_2' + 3 + a_3 + a_4 + a_5 + a_6 & = 12\\ a_1' + a_2' + a_3 + a_4 + a_5 + a_6 & = 6 \tag{3} \end{align*} Equation 3 is an equation in the positive integers with one solution. Hence, there are $$\binom{6}{2}\binom{5}{5}$$ cases in which two variables exceed $3$.
By the Inclusion-Exclusion Principle, the number of solutions of equation 1 in which no variable exceeds $3$ is $$\binom{11}{5} - \binom{6}{1}\binom{8}{5} + \binom{6}{2}\binom{5}{5}$$