<s>[INST] Different result of counting number between 1 and 2000 which the sum of all the digits is 25. How many number between 1 and 2000 which the sum of all the digits is 25?
I have tried to answer in two ways.
First way
Let the digits is $A$, $B$, $C$, and $D$.
$A+B+C+D=25$ with $A\leq 1$, $B\leq 9$, $C\leq 9$, and $D\leq 9$.
I am using transformation $E=1-A$, $F=9-B$,  $G=9-C$, $H=9-D$. We have new equation
$$E+F+G+H=28-25=3,$$
with $E\geq 0$, $F\geq 0$, $G\geq 0$, and $H\geq 0$.
So, we have the number between 1 and 2000 which the sum of all the digits is 25 is
$$
\begin{pmatrix}
4+3-1\\
3
\end{pmatrix}
=
\begin{pmatrix}
6\\
3
\end{pmatrix}
=
20 \text{ numbers}.
$$
Second way
Compute 3 digits number which the sum is 25.
Let $A=0$.
$B+C+D=25$ with $B\leq 9$, $C\leq 9$, and $D\leq 9$
I am using transformation $F=9-B$,  $G=9-C$, $H=9-D$. We have new equation
$$F+G+H=27-25=2,$$
with $F\geq 0$, $G\geq 0$, and $H\geq 0$.
So, we have the number 3 digits which the sum of all the digits is 25 is
$$
\begin{pmatrix}
3+2-1\\
2
\end{pmatrix}
=
\begin{pmatrix}
4\\
2
\end{pmatrix}
=
6\text{ numbers}.
$$
Let $A=1$.
$1+B+C+D=25\iff B+C+D=24$ with $B\leq 9$, $C\leq 9$, and $D\leq 9$
I am using transformation $F=9-B$,  $G=9-C$, $H=9-D$. We have new equation
$$F+G+H=27-24=3$$
with $F\geq 0$, $G\geq 0$, and $H\geq 0$.
So, we have the number 4 digits (1000-1999) which the sum of all the digits is 25 is
$$
\begin{pmatrix}
3+3-1\\
3
\end{pmatrix}
=
\begin{pmatrix}
5\\
3
\end{pmatrix}
=
10\text{ numbers}.
$$
So, we have the number between 1 and 2000 which the sum of all digits is 25 is
$$6+10=16\text{ numbers}.$$
My question
Why the result first way and second way is different?
I try to make list:
1996, 1987, 1978, 1969, 1897, 1888, 1879, 1798, 1789, 1699, 997, 988, 979, 898, 889, 799. There are 16 numbers.
Is the first way wrong?
 [/INST] The first way is incorrect.
Every combination of $A,B,C,D$ maps to a valid combination of $E,F,G,H$, such as $A=0, E=1$ and $A=1, E=0$. However, every combination of $E,F,G,H$ does not map to a combination of $A,B,C,D$: for example, $(E,F,G,H)=(3,0,0,0)$ leads to $A = -2$.
This means that you are counting solutions that are not valid in the original problem. In other words, you are overcounting in the first method.
In fact, there are four overcountings because when $E=3$, there is only one possibility for $F, G,H$, and when $E=2$ one of $F,G,H$ can be equal to $1$. When $E=1$ there is no issue. Thus there are four cases where you overcount.
</s>