How many combination can result to sum of 5? Given a scenario, 
There are five blocks. Each blocks can have only three numbers - 0,1,2.
We have to find out how many possible ways are there to get sum
For eg:-
1 | 1| 1 | 1 | 1. Which results to 5
2 | 1 | 2 | 0 | 0 which results to 5
 A: Step one would be to write down all combinations without caring about order.
$$ 5 = 2+2+1 = 2+1+1+1 = 1+1+1+1+1$$
Now for all three of these, count in how many ways we can reorder them to get different sequences. This might help:
link
A: It's the coefficient of $x^5$ in $(1+x+x^2)^5$, i.e. $51$.
Wolfram|Alpha
A: First, determine all the ways you can sum $5$ numbers from $\{0,1,2\}$ to get $5$ (there aren't very many). If you don't care about the order of the blocks, this is your answer.
If you do care about the order of the blocks, then for each combination, determine how many ways you can arrange the numbers on the $5$ blocks. E.g., for $0+0+2+1+2$, you have listed one possibility as $2|1|2|0|0$. How many others are there?
A: 2 | 1 | 2 | 0 | 0 which results to 5
make a transformation: add 1 to each block
It's the Problem: IntegerCompositions of $10$ to exactly $5$ sumands, with summand in $[1,3]$.

the number of IntegerCompositions of $n$ to $k$ summands with summand in $[1,r]$
$$
\left[z^n\right]\left(z+z^2+\ldots z^r\right)^k=\left[z^n\right]\left(z \frac{1-z^r}{1-z}\right)^k=\sum_j(-1)^j\left(\begin{array}{c}
k \\
j
\end{array}\right)\left(\begin{array}{c}
n-r j-1 \\
k-1
\end{array}\right)
$$
for your case,
$r=3,k=5,n=10$
Series Coefficient
SeriesCoefficient[(z*(1 - z^r)/(1 - z))^k /. {k -> 5, r -> 3}, {z, 
    0, #}] & /@ Range[10,10,1]


$$
\{51\}
$$
Binomial sum
a[n_, r_, k_] := 
 Sum[(-1)^j*Binomial[k, j]*Binomial[n - r*j - 1, k - 1], {j, 0, 
   Min[Floor[(n - k)/r], k]}]
a[#, 3, 5] & /@ Range[10, 10, 1]

$$
\{51\}
$$
