How many integer solutions are there to the equation : $$ x_{1} + x_{2} + x_{3} + x_{4} + x_{5} + x_{6} = 29 $$
$$ x_{1}\geq1, x_{2}\geq2, x_{3}\geq3, 10 \geq x_{4}\geq0, x_{5} > 5, x_{6}\geq -2$$
Could anyone explain me how to approach that ? Specially when it comes to the restriction of  $x_{4}$.
 A: Substitute $y_1 = x_1 -1$, $y_2 = x_2 -2$, $y_3 = x_3-3$, $y_4 = x_4$, $y_5 = x_5 - 5$ and $y_6 = x_6 + 2$ to get
$\;\;\;
    y_1 + y_2 + y_3 + y_4 + y_5 + y_6  = 20$ with $y_i\ge0$ for $1\le i\le6$ and $y_4\le10$.
We have to count how many ways to place 20 identical balls in 6 boxes, with the restriction that there are at most 10 balls in the 4th box.
Without any restrictions, there are $\binom{25}{5}$ ways to place the balls in the boxes, since this is the number of ways to arrange 20 balls and 5 dividers; and we have to subtract the number of distributions with 11 balls in box 4, which is equal to $\binom{14}{5}$ since there are 9 balls remaining and 5 dividers. 
Therefore the number of solutions is given by
$\binom{25}{5}-\binom{14}{5}$.
A: Rewrite the equation using $y_1 = x_1 -1$, $y_2 = x_2 -2$, $y_3 = x_3-3$, $y_4 = x_4$, $y_5 = x_5 - 5$ and $y_6 = x_6 + 2$:
$$
    y_1 + y_2 + y_3 + y_4 + y_5 + y_6 = 29 - 11 + 2 = 20
$$
It is then best to use the generating function approach. We find 
$$
   g(t) = \sum_{y_1, y_2, y_3, y_5, y_6 \geqslant 0} \sum_{10 \geqslant y_4 \geqslant 0} y^{y_1 + y_2 + y_3 + y_4 + y_5 + y_6} = \frac{1}{(1-t)^5} \frac{1-t^{11}}{1-t}
$$
The answer is $[t^{20}]g(t) = [t^{20}]\frac{1}{(1-t)^6} - [t^{20-11}] \frac{1}{(1-t)^6} = \binom{20+6-1}{6-1} - \binom{9+6-1}{6-1} = 51128$:
In[132]:= SeriesCoefficient[1/(1 - t)^5 (1 - t^11)/(1 - t), {t, 0, 20}]

Out[132]= 51128

Confirmation by direct counting:
In[134]:= Sum[1, {y4, 0, 10}, {y1, 0, 20 - y4}, {y2, 0, 
  20 - y4 - y1}, {y3, 0, 20 - y4 - y1 - y2}, {y5, 0, 
  20 - y4 - y1 - y2 - y3}]

Out[134]= 51128

The generating function provides with an insight to tackle the problem directly by using $\{0 \leqslant y_4 \leqslant 10\} = \{ 0 \leqslant y_4\} \backslash \{11 \leqslant y_4\}$.
A: Define new variables say y's instead of x's such that y1=x1 -1, etc.Hence y1 will always be greater than or equal to zero. Do similar substitutions for all x's and formulate the question in terms of y's only.Now that all variables are positive, model this question as balls-boxes problem.That is you have m balls and you have to distribute them in n boxes (Here your variables are boxes and the total number of balls is the number obtained in place of 29 after substitution).This can be done easily.
