Sunday Times Teaser 3311 – Calling From Home
by Andrew Skidmore
Published Sunday March 08 2026 (link)
Edna is charged a single digit number of pence for each call to a mobile. A smaller whole number of pence is charged for every minute or part minute for which each mobile call exceeds five minutes. She spent exactly an hour in real time on mobile calls with the shortest call being less than a minute and each of the other four calls rounding up to different prime numbers of minutes. Curiously, the product of the primes is a palindrome; the sum of its digits being a single digit odd number.
The total charge for the five calls was a palindromic number of pence. If I told you whether that number was odd or even, you would know what it was.
In increasing order, what are the two palindromic numbers?
Here is an alternative approach.
Brian here is a version of your code above with simplification of lines 24 – 37 taking into account that for a palindrome to sum to an odd number, it must have an odd number of digits
Yes, I missed that issue. Starting with the palindrome is a lot slower than the earlier alternative. However the speed can be competitive, albeit with a lot of additional code
Using Brian’s alternate approach, stop the search if one parity has one cost and the other more than one. This reduces execution time significantly while adding only two lines of code.
An amalgam of the two methods with various tweaks. The last two of three conditions in the ‘if’ statement of line 28 appear to be redundant but this is hard to prove, so: belt and braces.