# Sunday Times Teaser 2830 – Time for Christmas

*by Danny Roth*

#### Published: 18 December 2016 (link)

For Christmas George has bought Martha a novelty digital 24-hour clock. It has an eight-digit display forming four two-digit numbers. The first three of these two-digit numbers are very conventional – the hours, the minutes and the seconds. However, the final two-digit display shows the sum of the first six displayed digits!

On two occasions today all eight digits displayed were different and three of the four two-digit numbers were perfect squares. Between those two occasions there was a time when the eight digits displayed were again all different, but this time the sum of the eight digits was a perfect square!

What was the eight-digit display at that in-between time?

If we accept that there are only “two occasions” in any given day, then we don’t need to consider all the times, just look until we find the second condition (p2) occurring between the two occurrences of the first condition (p1).

This code stops when it finds the second occurrence of the first condition and runs in 96ms.

We could stop when we hit the first p2 condition after seeing a p1, but this gives you the times of the p1’s and also all the intermediate p2’s (although as expected there is only one).

The

enigma.pylibrary is available from [ htto://www.magwag.plus.com/jim/enigma.html ].