Determine the number of integer solutions of the equation $ x_{1}+x_{2}+x_{3}+x_{4}=20 $ Determine the number of integer solutions of the equation
$$
x_{1}+x_{2}+x_{3}+x_{4}=20
$$
under the restrictions:
$$
\begin{array}{l}
2 \leq x_{1} \leq 6 \\
0 \leq x_{2} \leq 5 \\
2 \leq x_{3} \leq 8 \\
2 \leq x_{4} \leq 6
\end{array}
$$
I did $x_1=y_1+2$ then $0\leq y_1 \leq4$
$x_2=y_2$ then $0\leq y_2 \leq5$
$x_3=y_3+2$ then $0\leq y_3 \leq6$
$x_4=y_4+2$ then $0\leq y_4 \leq4$
So $y_1+y_2+y_3+y_4 \leq 19$
So the number of solutions is
$\sum_{k=0}^{19}\left(\begin{array}{c}
k+3 \\
k
\end{array}\right)=\sum_{k=0}^{19}\left(\begin{array}{c}
k+3 \\
3
\end{array}\right)$
is right?
 A: The combined values of the maximum value for the $x$'s is 25. We can then take four part ordered partitions of $5$ (including zeros) and subtract each of those from the maximum.
The first set of partitions is $(5,0,0,0)$ with the $5$ being in four potential locations.
You cannot subtract $5$ from $x_1$ or $x_4$ so there are $2$ ways of doing this.
The second set of partitions is
$(4,1,0,0)$. There are $12$ ways of ordering these numbers.
The third set of partitions is $(3,2,0,0)$.There are $12$ ways of ordering these numbers.
The fourth set is $(3,1,1,0)$.There are $12$ ways of ordering these numbers.
The fifth set is $(2,2,1,0)$.There are $12$ ways of ordering these numbers.
Finally the sixth and last set is $(2,1,1,1)$. There are four locations for the $2$. Therefore there are $4$ ways of ordering these numbers.
$2+12+12+12+12+4=54$
There are $54$ solutions to the equation $x_1+x_2+x_3+x_4=20$.
A: Actually there is a trick to do this, to remove inequality introduce a new dummy variable :
$$ y_1 + y_2 + y_3 + y_4 + c =19$$
Now, this represent same as inequaliy if we let $ c$ vary from $[0,19]$, can you think why? [Well I couldn't haha :P, see my question about it here]
After this use generating functions as shown in this post
Comment on your method:
Stars and bars method of finding solutions assumes constraints on each variable is same, in your question each variable has different upper limit , so it doesn't work. See the derivation for formula for understanding why. A modified version however works see here( Thanks to  user2661923's comment)
