What's the ammount of solutions to the Equation $A+B+C+D=24$ with restrictions on $A$ and $B$ As the title says, I have the the following equation:
$A+B+C+D=24$
$2\leq A\leq 5$ and $4\leq B\leq 7$
And i need to find the number of possible solutions. $A,B,C,D\geq 0$, They are integers.
I'm not sure if my solution is right, What i did is:
I've made a new equation stating $A_1=A-2$ and $B_1=B-4,$ So i get:
$A_1+B_1+C+D=30.$
So my restrictions now are $0\leq B \leq 3$, Marking $A_1+B_1=S, S=[0,6],$ Means:
$C+D=30-S $ And the number of possibilities for that one is $31-S$.
So now i need to do the sum: $\sum (31-S)$ from $S=0$ to  $ S=6$ and multiply it by $3^2 \;$ [Which represents the different combinations of $A$ and $B$] so that equals to: $1774.$
Did I do something wrong or it seems fine?
 A: By using ordinary generating function:
let $A=g_1(x)=(x^2+x^3+x^4+x^5)=x^2(1+x+x^2+x^3)$
let $B=g_2(x)=(x^4+x^5+x^6+x^7)=x^4(1+x+x^2+x^3)$
let $C=g_3(x)=(1+x+x^2+\dots\dots)$
let $D=g_4(x)=(1+x+x^2+\dots\dots)$
Then $G(x)=g_1(x)g_2(x)g_3(x)g_4(x)=x^6\frac{(1-x^4)^2}{(1-x)^2}\frac{1}{(1-x)^2}=x^6\frac{1-2x^4+x^8}{(1-x)^4}$, now you need to find $[x^{18}]$ in $\frac{1-2x^4+x^8}{(1-x)^4}$, then you get
$$\binom{18+4-1}{4-1}-2\binom{14+4-1}{4-1}+\binom{10+4-1}{4-1}=256$$
A: I think you're trying to simplify things, but you're making some arithmetic errors in the process.  Firstly, you should subtract 6 both sides, rather than subtracting 6 on the left, and adding it on the right.  Then there's some other bugs noted in the comments.  But you needn't do any of this anyway.
As you point out, the number of non-negative integer solutions to $C+D=24-A-B$ (once the values of $A$ and $B$ are decided) is indeed $24-A-B+1$: the solutions are $$(C,D) \in \big\{(i,24-A-B-i):i \in \{0,1,\ldots,24-A-B\}\big\}.$$
Now we can just do the bookkeeping.  The following lists the possible values of $(A,B)$, denoted [ A, B ] along with the value of $24-A-B+1$.
[ 2, 4 ] 19
[ 2, 5 ] 18
[ 2, 6 ] 17
[ 2, 7 ] 16
[ 3, 4 ] 18
[ 3, 5 ] 17
[ 3, 6 ] 16
[ 3, 7 ] 15
[ 4, 4 ] 17
[ 4, 5 ] 16
[ 4, 6 ] 15
[ 4, 7 ] 14
[ 5, 4 ] 16
[ 5, 5 ] 15
[ 5, 6 ] 14
[ 5, 7 ] 13

We add this up to give 256.
A: You've had a good idea to set $A_1=A-2$ and $B_1=B-4$, but from there, you start having issues. We can rewrite $A=A_1+2$ and $B=B_1+4$ to give us $$A_1+B_1+C+D+6=24,$$ or $$A_1+B_1+C+D=18,\tag{1}$$ with our new constraints that $A_1,B_1,C,D$ are all nonnegative integers with $A_1\le3$ and $B_1\le 3$.
As you note in the comments, there are $16$ pairs $A_1,B_1$ that meet our constraints. However, there are not $16$ different ways to make $A_1+B_1=S$ for each integer $0\leq S\leq 6$. Consider the following table of sums: $$\begin{array}{c|cccc}& 0 & 1 & 2 & 3\\\hline\\0 & 0 & 1 & 2 & 3\\1 & 1 & 2 & 3 & 4\\2 & 2 & 3 & 4 & 5\\3 & 3 & 4 & 5 & 6\end{array}$$ In general, then, given an integer $0\le S\le 6$, there are $$\min\{S,6-S\}+1=4-|3-S|$$ ways to choose $A_1,B_1$ meeting our constraints such that $A_1+B_1=S$.
Now, given any integer $0\le S\le 6,$ there are indeed $19-S$ ways to choose nonnegative integers $C,D$ such that $S+C+D=18$. Hence, the sum you're looking for is $$\begin{align}\sum_{S=0}^6\bigl(4-|3-S|\bigr)(19-S) &= 1\cdot 19+2\cdot 18+3\cdot 17+4\cdot 16+3\cdot 15+2\cdot 14+1\cdot 13\\ &= 19+36+51+64+45+28+13\\ &= 256.\end{align}$$
