A four-digit number $a b c d$ is called balanced if

$$
a+b=c+d
$$

Calculate the following quantities:

a) How many numbers $a b c d$ are such that $a+b=c+d=8$ ?

b) How many numbers abcd are such that $a+b=c+d=16$ ?

c) How many balanced numbers exist?
Solution

a) Let's first count the possible values for the pair $(a, b)$. Note that $a$ cannot be equal to zero, as it is the first digit in $abcd$. However, $a$ can take any value in

$$
\{1,2,3,4,5,6,7,8\}
$$

because for each of these values, the number 8 - $a$ results in an appropriate value for $b$. Thus, there are 8 possibilities for the pair $(a, b)$. To count the possible values for the pair $(c, d)$, it is enough to see that $c$ can take any value in the set

$$
\{0,1,2,3,4,5,6,7,8\}
$$

and for each of these values, the number $8-c$ results in an appropriate value for $d$. Thus, there are 9 possibilities for the pair $(c, d)$. The numbers $abcd$ that satisfy $a+b=c+d=8$ are the combinations of $ab$ and $cd$. The answer is, therefore,

$$
8 \times 9=72
$$

b) Let's start by counting the possibilities for the pair $(a, b)$. Note that if $a$ were less than 7, the number 16 - $a$ would be negative and would not, then, be an appropriate value for $b$. Therefore, the possible values for $a$ are

$$
\{7,8,9\}
$$

Thus, there are 3 possibilities. Now observe that for the pair $(c, d)$, the possibilities are exactly the same as for $(a, b)$:

$$
(7,9), \quad(8,8) \quad \text { and } \quad(9,7)
$$

Finally, the numbers $abcd$ we are looking for result from combining the possibilities for $ab$ and $cd$. The answer is, therefore,

$$
3 \times 3=9
$$

c) We need to count the numbers $abcd$ such that $a+b=c+d$. First, let's count those in which $a+b=c+d=s$ for a $1 \leq s \leq 9$. The possibilities for the pairs $(a, b)$ and $(c, d)$ in these cases are calculated similarly to part a). The possible values for $a$ are

$$
\{1,2, \ldots, s\}
$$

because for all these values, the number $s-a$ is an allowed value for $b$. Thus, there are $s$ possibilities for the pair $(a, b)$. On the other hand, the allowed values for $c$ are

$$
\{0,1,2, \ldots, s\}
$$

because for all these values, the number $s-c$ is an allowed value for $d$. We now count $s+1$ possibilities for the pair $(c, d)$. Finally, by combining the possibilities for the pairs $(a, b)$ and $(c, d)$, we count

$$
s \times(s+1)
$$

numbers $abcd$ such that $a+b=c+d=s$, with $s \in\{1,2, \ldots, 9\}$. Considering all values of $s$ from 1 to 9, we have in total

$$
1 \times 2+2 \times 3+\cdots+9 \times 10=330
$$

numbers $abcd$ such that $1 \leq a+b=c+d \leq 9$.

Note that the maximum possible value for $a+b=c+d=s$ is 18. There is still the case to consider where $10 \leq s \leq 18$. For $s-a$ to be an allowed value for $b$, it is necessary that $0 \leq s-a \leq 9$. This implies that

$$
s-9 \leq a \leq s
$$

But since $a$ must be less than or equal to 9, the possible values for $a$ will be

$$
\{s-9, s-8, \ldots, 9\}
$$

When $10 \leq s \leq 18$, it is easy to verify that all these values are allowed for $a$, because $s-a$ is also an allowed value for $b$. Thus, we count $19-s$ possibilities for the pair $(a, b)$. On the other hand, as in part b), the possibilities for the pair $(a, b)$ are exactly the same as for the pair $(c, d)$. By combining, we get $(19-s) \times(19-s)$ possibilities for $abcd$ with $a+b=c+d=s$ and $s \in\{10,11, \ldots, 19\}$. Considering the sums $s$ from 10 to 18, we count

$$
9^{2}+8^{2}+7^{2}+\cdots+1^{2}=285
$$

numbers $abcd$ such that $10 \leq a+b=c+d \leq 18$. Finally, the answer is that there are $330+285=615$ numbers $abcd$ such that $a+b=c+d$.