Teaser 3312: Never ends rumbas
From The Sunday Times, 15th March 2026 [link] [link]
Whether or not Reverend Spooner really did accidentally swap over the sounds of initial bits of words (or wits of birds?) with amusing results, we might wonder if he did the same thing with numbers.
He might have prepared a list of all possible pairs of three-digit prime numbers, for which each pair became square numbers when the first digit of the first number was exchanged with the first digit of the second number. He might have put each pair of primes in numerical order, and might then have put the pairs overall in numerical order.
I’m not trying to start a rumour that this really happened. Like spoonerisms of words, this is just for amusement.
What would have been the list of the Reverend’s numbers?
[teaser3312]



Jim Randell 6:50 am on 15 March 2026 Permalink |
By looking at possible pairs of (odd) squares, and then looking to see if the numbers in the swapped pair are primes we can significantly reduce the number of pairs to consider.
This Python program runs in 76ms. (Internal runtime is 167µs).
from enigma import (primes, powers, subsets, ordered, printf) # 3-digit primes primes.expand(999) # collect the list of primes rs = list() # consider possible (odd) 3-digit squares for (sq1, sq2) in subsets(powers(11, 31, 2, step=2), size=2): # swap the leading digits over ((h1, t1), (h2, t2)) = (divmod(n, 100) for n in [sq1, sq2]) if h1 == h2: continue (pr1, pr2) = (100*h + t for (h, t) in [(h2, t1), (h1, t2)]) # check for primes if not (pr1 in primes and pr2 in primes): continue printf("[squares = ({sq1}, {sq2}) <-> primes = ({pr1}, {pr2})]") rs.append(ordered(pr1, pr2)) # output result printf("prime pairs = {rs}", rs=sorted(rs))Solution: [To Be Revealed]
LikeLike
Ruud 7:13 am on 15 March 2026 Permalink |
import istr istr.repr_mode("int") print([(p0, p1) for p0, p1 in istr.combinations(istr.primes(100, 1000), r=2) if (p1[0] | p0[1:]).is_square() and (p0[0] | p1[1:]).is_square()])LikeLike