# Sunday Times Teaser 2798 – Housey-Housey

### by Robin Nayler

#### Published: 8 May 2016 (link)

Philip, Daphne and I live in different houses on Teaser Drive. Philip lives at number 1 and the houses are then numbered consecutively along one side of the road. The sum of the house numbers strictly between Philip’s house and mine is equal to the sum of the house numbers strictly between my house and Daphne’s. Furthermore, the digits of Daphne’s house number add up to the same total as the digits of my house number.

What is my house number and what is Daphne’s?

Here is another solution based on a bit of analysis. If we let his number be $$m$$ and Daphne’s number be $$d$$, we can equate the sums of the numbers of the houses between Peter’s, his and Daphne’s houses as:

$m(m-1)/2-1=d(d-1)/2 – m(m+1)/2$ After a bit of algebraic manipulation this can be transformed into the equation: $(2d-1)^2-2(2m)^2=-7$

which is a quadratic diophantine equation (QDE) for which I have a solver in my number theory library. This hence provides the alternative solution:

which gives multiple solutions as follows:

After solving with paper & pencil I decided to have some fun & as with many teasers used Brian’s letter/number python solver again for this one. Using similar algebraic manipulation as Brian above:
$2M^2=D^2-D+2$

If we assume they both have 2 digit house numbers, then let $$M=10a+b$$ and $$D=10c+d$$ giving $$a+b=c+d$$ where all 4 digits must be different – so ideal for the solver.

All that was then necessary was to enter the following into the solver:

2*(10*a+b)**2 == (10*c+d)**2 – 10*c – d + 2 & a + b == c + d

I now see that my statement above that all 4 digits must be different was incorrect.
E.g. M=11 & D=20, M=12 & D=21 or 30, M=68 & D=77 etc.
Also the solver would exclude any b or d = 0.
Thus I just got lucky that the solution didn’t contain repeat digits or a 0!
However if this wasn’t the case it would have eliminated most possibilities & allowing solving much easier anyhow.

4. Using R for the setters house number and D for Daphne’s house number, from the “inter-sum” condition we can derive:2R² = D² − D + 2

The R numbers follow OEIS A006452 [ https://oeis.org/A006452 ] which can be generated by:

A[0, 1, 2, 3] = [1, 1, 2, 4]
A[n] = 6 A[n − 2] − A[n − 4]

For each R we can look for a corresponding D using the quadratic equation above.

The number of solutions this Python 3 program generates can be specified on the command line:

Note: Some routines from the enigma.py library are used. The library can be downloaded from [https://www.magwag.plus.com/jim/enigma.html ].

• Or more simply: