Find number of solutions $ x_1+x_2+x_3+x_4+x_5+x_6+x_7 = 7 $ where $x_i \in \left\{ 0,1,2 \right\}$

combinatoricsdiscrete mathematics

Find number of solutions
$$ x_1+x_2+x_3+x_4+x_5+x_6+x_7 = 7 \text{ such that } \forall_i x_i \in \left\{0,1,2\right\}$$
I know how I can do this when I don't have restriction $\forall_i x_i \in \left\{0,1,2\right\}$:
$$ ooooooooooooo \text{ n+(k-1) = 7 + (7-1) = 13 balls }$$
$$ oo||o|oo|o|o| \text{ k-1 = 6 balls I replace with sticks }$$
and I have $$ 2 + 0 + 1 + 2 + 1 + 1 + 0 = 7 $$
I can do this in $$ \binom{n+k-1}{k} = \binom{13}{7} $$ ways. But how to deal with additional restriction?

Best Answer

Hint: The answer is the coefficient of $x^7$ in $(1 + x + x^2)^7$.

Related Question