TITLE: In how many $4$-digit numbers the sum of two right digits is equal to the sum of two left digits
QUESTION [9 upvotes]: In how many $4$-digit numbers the sum of two right digits is equal to the sum of two left digits.
My attempt:We should find number of two pairs that can be digits of this number for choosing the place of digits we have $*8$ (We should notice we cant have $0$ in the beginning.But the biggest problem is finding such pairs.How can I find them?

REPLY [2 votes]: This problem can be solved using Stars and Bars method.
Let the digits be $a,b,c,d$.
Then we must find integral solutions of $$a+b=c+d \Rightarrow a+b-c-d=0$$
with restrictions on $a,b,c,d\ $ i.e $1\le a\le 9$ and $0\le \{b,c,d\}\le 9$
The equation can be transformed by taking $a=x_1+1,\ b=x_2,\ c=9-x_3,\ d=9-x_4$ to:
$$\begin{align}&x_1+1+x_2+x_3-9+x_4-9=0\\\Rightarrow \ \ &x_1+x_2+x_3+x_4=17\end{align}$$
with $0\le x_1\le 8$, $0\le \{x_2,x_3,x_4\}\le 9$
The number of integral solutions of above equation can be solved using the Stars and Bars method.
Try yourself or see below for rest of the procedure:

Number of solutions for $$x_1+x_2+x_3+ x_4 = 17\\$$ where $x_i \ge 0$
  for $i = 1,2,3,4$ is $\binom{17+4-1}{17}=\binom{20}{3}$ solutions.
We have to remove cases where $x_1\ge9$ and $\{x_2,x_3,x_4\}\ge10$,
  let's say $x_1$ for example, is $\ge 9$, then we can find all the
  number of solutions to be excluded by putting $y_1 = x_1 - 9$, we can
  write $$y_1 + x_2 +x_3+x_4 = 8$$ which has
  $\binom{8+4-1}{8}=\binom{11}{3}$ solutions.
Similarly for $x_i\ge 10$ for $i=2,3,4$, then we can find all the
  number of solutions to be excluded by putting $y_i = x_i - 10$, we can
  write, for e.g. $x=2$, $$x_1 + y_2 +x_3+x_4 = 7$$ which has
  $\binom{7+4-1}{8}=\binom{10}{3}$ solutions.

Hence total number of such 4-digit numbers is:
$$\binom{20}{3}-\binom{11}{3}-3\times\binom{10}{3}=615$$