# One-to-one correspondence between these two problems?

How many 3-digit positive integers are there whose middle digit is equal to the sum of the first and last digits?

I noticed that the solution to this problem, $45$, is the same as the solution to the problem

How many 3-digit positive integers are there whose middle digit is the average of the first and last digits?

Is this purely a coincidence or is there some sort of a bijection/one-to-one correspondence that links these two?

• I am not completely sure, but it is not clear to me, what a bijection between two problems should be, when the problems have no free parameters, like the bijection between two fixed numbers 23 and 42. Shouldn't it be simply 23 $\leftrightarrow$ 42, or "sum" $\leftrightarrow$ "average"? – flonk Jan 11 '14 at 22:38
• Presumably what is being asked for is a reasonable bijection between the solution sets to the two problems. – Greg Martin Jan 11 '14 at 22:42
• Yes -- I want to know why (if it is not just a coincidence) both answers come out to be the same. It seems like they could be related. – 1110101001 Jan 11 '14 at 22:43
• @GregMartin Of course, there is because both sets have the same size. But I guess for an insightful answer, one might have to find generalized problems. – flonk Jan 11 '14 at 22:44
• @flonk There is a pretty obvious generalization, from base $10$ to base $b$. – bof Jan 11 '14 at 23:07

Note that in both problems, the middle digit (if valid) is determined by the first and last digits.

There are 90 possible pairs of first and last digits $(f,\ell)$, since $1\le f\le 9$ and $0\le\ell\le9$. These can be grouped into 45 pairs $\{ (f,\ell), (10-f,9-\ell) \}$.

Note that exactly one member of each such pair leads to an answer to the first problem: exactly one of $f+\ell$ and $(10-f)+(9-\ell)$ is between 0 and 9, since the two sums add to 19.

Note also that exactly one member of each such pair leads to an answer to the second problem: exactly one of $\frac12(f+\ell)$ and $\frac12((10-f)+(9-\ell))$ is an integer, because the two expressions add to $\frac{19}2$ and both are half-integers.

Therefore the trivial bijection between the sets of 45 pairs induces a bijection between the solution sets of the two problems. For example, $110, 121, 132, 143$ are bijectively mapped to $999, 111, 987, 123$ respectively, while the preimages of $333, 345, 357, 369$ are $363, 385, 792, 770$ respectively.

• And of course it works for any radix. – bof Jan 11 '14 at 23:05
• Sorry to comment on this question after such a long time, but is there any reason why the bijection is between $(f,l)$ $\to$ $(10-f,9-l)$? Can it be between $(f,l)$ and $(9-f,10-l)$? – 1110101001 Apr 12 '14 at 4:49
• What would the image of $990$ be then? – Greg Martin Apr 12 '14 at 5:49

Let $S=\{(a,b,c): b=a+c\}$ and $T=\{(a,b,c): b=\frac{a+c}{2}\}$, with $1\le a\le 9$ and $0\le b,c\le9$.

Define $f:S\rightarrow T$ by $f(a,b,c)=\begin{cases} (\;\;\;a,\;\;\;\;\;\frac{b}{2},\;\;\;\;c) & \mbox{, if b is even}\\(10-a,\frac{19-b}{2},9-c) & \mbox{, if b is odd} \end{cases}$.

Then f defines a bijection between S and T, with inverse $g:T\rightarrow S$ defined by

$\;\;\;\;\;\;\;\;g(a,b,c)=\begin{cases} (\;\;\;a,\;\;\;\;\;\;2b,\;\;\;\;\;\;\;c) & \mbox{, if$0\le b\le4$}\\(10-a,19-2b,9-c) & \mbox{, if$5\le b\le 9$} \end{cases}$.