The following number puzzle was published in the Sunday Times on 25th August this year. It is credited to Danny Roth.
George and Martha have a book of puzzles numbered from 1 to 30. The solutions are also numbered from 1 to 30, but a solution number is not necessarily the same as the number of the puzzle. George and Martha have solved some of the puzzles. If you look at the number of the puzzle and the number of the solution, then the sum of the two is a perfect power of the difference of the two. George has added up the numbers of the solved puzzles and got a three-figure total. Martha has added up the numbers of the solutions of the solved puzzles and got a higher three-digit total. In fact her total used the same non-zero digits as George's, but in a different order. What (in increasing order) are the numbers of the solved puzzles?
I seem to have deduced that no solution exists. This indicates that I have probably either made a mistake in my reasoning, or misinterpreted some part of the question. Maybe someone can tell me which it is and what is the nature of my error. What follows is my reasoning.
Let $\mathbb{N}_{30}$ denote the set $\{1, 2, 3, \ldots, 30\}$. Let $f \colon \mathbb{N}_{30} \to \mathbb{N}_{30}$ be the permutation that takes each puzzle number to the number of the corresponding solution. We are given that for each $i \in \mathbb{N}_{30}$ there exists an integer $j$ such that $f(i) + i = |f(i) - i|^{j}$. Let $r \colon \mathbb{N}_{30} \to \mathbb{Z}$ be the function that takes each $i$ to its corresponding $j$.
- For each $i \in \mathbb{N}_{30}$, we have $2 \leq f(i) + i \leq 60$. Immediate.
- For each $i \in \mathbb{N}_{30}$, we have $f(i) \neq i$. Indeed, if $f(i) = i$ then every (well-defined) integer power of $|f(i) - i|$ is either 0 or 1. But this contradicts the lower bound in (1).
- For each $i \in \mathbb{N}_{30}$, we have $|f(i) - i| \neq 1$. Indeed, if $|f(i) - i|$ is equal to 1 then so is its every integer power, and this again contradicts the lower bound in (1).
- For each $i \in \mathbb{N}_{30}$, we have $2 \leq |f(i) - i| \leq 7$. That $|f(i) - i| \geq 2$ follows from (2) and (3). Suppose for a contradiction that $|f(i) - i| \geq 8$. We know that $r(i) \geq 2$ since $|f(i) - i|^{r(i)}$ is an integer, and greater than 1 (by the lower bound in (1)). Now $|f(i) - i| \geq 8^2 = 64$, which contradicts the upper bound in (1).
- $f(1) = 3$, and $f(3) = 1$. By (4), $f(1)$ must be 3, 4, 5, 6, 7 or 8. The only one of these that satisfies the "perfect power" requirement is 3, so $f(1) = 3$. A similar argument establishes that $f^{-1}(1) = 3$.
- No possible values for $f(2)$. By (4) and (5), $f(2)$ must be 4, 5, 6, 7, 8 or 9. None of these satisfy the "perfect power" requirement.
Unless I've also misunderstood the task, there are at least two solutions:
This is the PERL program (I'm aware that it's messy and unoptimized) I used to solve this: