How many solutions are there to the sum $x+y+z+w = 12$ when $x \geq 4$ and $y \leq 3$? I am currently trying to work out how many integer solutions there are to the sum 
$$x+y+z+w = 12$$
when $x \geq 4$ and $y \leq 3$ (and $z,w \geq 0$).
I have worked out that 


*

*With $x,y,z,w \geq 0$ the number of solutions is $455$.

*With $x \geq 4$ and $y,z,w \geq 0$ the number of solutions is $165$.

*With $y \leq 3$ and $x,z,w \geq 0$ the number of solutions is $290$.


but I have been unable to proceed from here. Can anyone help me to deduce the answer to this one?
 A: $$(x-4)+y+z+t = 8$$
Let $x'=x-4$.
For $y=0$ we have $x'+z+t =8$ so we have ${10\choose 2} =45 $ solutions.
For $y=1$ we have $x'+z+t =7$ so we have ${9\choose 2} =36 $ solutions.
For $y=2$ we have $x'+z+t =6$ so we have ${8\choose 2} =28 $ solutions.
For $y=3$ we have $x'+z+t =5$ so we have ${7\choose 2} =21 $ solutions.
So we have $130$ solution to this equation.
A: Try to transform the problem to the problem: $t+y+z+w = 8$, where $t = x-4, t \ge 0$.
A: Just replace $x$ by $x'=x-4$ and search for solutions for $x'+y+z+w=8$, and $y\le 3$. We split into four cases, corresponding to the possible values of $y$, namely $0,1,2,3$. So we need to know the numbers for the partitions of $8$, respectively $7$, respectively $6$, respectively $5$, in three pieces. These can be obtained recursively.
Instead, i will use sage code, a one line computation:
sage: len( [ S for S in cartesian_product( [ [4..12], [0..3], [0..8], [0..8] ] ) if sum(S) == 12 ] )
130

Note:
Same code recovers the already computed numbers:
sage: len( [ S for S in cartesian_product( [ [0..12], [0..12], [0..12], [0..12] ] ) if sum(S) == 12 ] )
455
sage: len( [ S for S in cartesian_product( [ [4..12], [0..12], [0..12], [0..12] ] ) if sum(S) == 12 ] )
165
sage: len( [ S for S in cartesian_product( [ [0..12], [0..3], [0..12], [0..12] ] ) if sum(S) == 12 ] )
290

A: Factor your problem:
Let $N_{i}$
  be the number of solutions to $x+z+w=8-i$
  for $i=0,\dots,3$
  without any constraint. This is the number of solutions to $x+y+z+w=12$
  with the constraints $x\geq4$
  und $y=i$.
Furthermore for define $M_{i}^{j}$
  for $i=0,\dots,3$
  and $j=0,\dots,8-i$
  as the number of solutions to $z+w=8-i-j$. This is the number of solutions to $x+y+z+w=12$
  with the constraints $x=4+j$
  and $y=i$.
We have $M_{i}^{j}=8-i-j+1$.
Thus the total number you need to know is $$\sum_{i=0}^{3}\sum_{j=0}^{8-i}\left(8-i-j+1\right)$$
 Now you just need to find the laziest way to calculate this. XD
(Hint: its 130)
A: I usually solve such question by applying inclusion and exclusion. Here we are also going to use the stars and bars method:
X - set of all solutions when $x≥4$ and $y≤3$ (and $z,w≥0$). 
|X|  = $12+4-1\choose 4-1$  (4-1 since we have 4 objects, so 3 separators)
Here we are taking the negation of them and we exclude the answer from the total number of solutions.
S1 - Solutions where $x<=3$
S2 - Solutions where $y>=4$
|S1| = $12+3+3 \choose 3$
|S2| = $12-4+3 \choose 3$
$|S1 \cap S2|$ $=$ $ 12 -4 +3 +3 \choose 3$
$|S1 \cup S2|$ $=$ $|S1| + |S2| - |S1 \cap S2|$ 
Answer: $|x| - |S1 \cup S2|$ $=$ $12+4-1\choose 4-1$ - ($12+3+3 \choose 3$ + $12-4+3 \choose 3$ - $12 -4 +3 +3 \choose 3$)
The answer I am getting: $455 - (816+165-364)$ ..
That would be negative so there is something that I am doing wrong, but this is how they usually solve such questions and I am still learning, and waiting for someone to correct me as well :)
A: We wish to solve the equation 
$$x + y + z + w = 12 \tag{1}$$
in the nonnegative integers subject to the restrictions $x \geq 4$ and $y \leq 3$.  
To handle the restriction $x \geq 4$, let $x' = x - 4$.  Then $x'$ is a nonnegative integer.  Substituting $x' + 4$ for $x$ in equation 1 yields
\begin{align*}
x' + 4 + y + z + w & = 12\\
x' + y + z + w & = 8 \tag{2}
\end{align*}
Equation 2 is an equation in the nonnegative integers.  The number of nonnegative integers solutions of equation 2 subject to the restriction $y \leq 3$ is equal to the number of nonnegative integer solutions of equation 1 subject to the restrictions $x \geq 4$, $y \leq 3$.
If we ignore the restriction $y \leq 3$ for the moment, a particular solution of equation 2 corresponds to the placement of three addition signs in a row of eight ones.  For instance, 
$$1 1 1 + 1 1 + + 1 1 1$$
corresponds to  the solution $x' = 3$ ($x = 7$), $y = 2$, $z = 0$, $w = 3$.  The number of such solutions is the number of ways we can select which three of the eleven positions required for eight ones and three addition signs will be filled with addition signs, which is 
$$\binom{8 + 3}{3} = \binom{11}{3}$$
From these, we must subtract those cases in which the restriction $y \leq 3$ is violated.
Suppose $y > 3$.  Then $y' - 4$ is a nonnegative integer.  Substituting $y' + 4$ for $y$ in equation 2 yields
\begin{align*}
x' + y' + 4 + z + w & = 8\\
x' + y' + z + w & = 4 \tag{3}
\end{align*}
Equation 3 is an equation in the nonnegative integers.  Since a particular solution corresponds to the placement of three addition signs in a row of four ones, equation 3 has 
$$\binom{4 + 3}{3} = \binom{7}{3}$$
solutions in the nonnegative integers.  
Thus, the number of solutions of equation 1 in the nonnegative integers that satisfy the restrictions $x \geq 4$ and $y \leq 3$ is 
$$\binom{11}{3} - \binom{7}{3}$$
