Teaser 3326: Interesting figures
From The Sunday Times, 21st June 2026 [link] [link]
At a cricket match Tom Leggie bowled fewer than 100 overs (O), of which fewer than 10 were maidens (M), took more than one but fewer than 11 wickets (W), and had an average of runs conceded per over (R/O) that was less than 6.
I noticed something interesting about his bowling analysis (O-M-R-W): writing the numbers together with no gaps or overlap, then reading from right to left, they comprised a perfect square followed immediately by a prime with the same number of digits, and they could also be read (again in their entirety, right to left) as a prime number followed by a perfect square number with more digits. None of the perfect squares or primes was a single digit, and no zeros were involved.
What was Tom’s bowling analysis (O-M-R-W)?
[teaser3326]
Jim Randell 7:41 am on 21 June 2026 Permalink |
A brute force solution determines the numbers involved in an acceptable time.
The following Python program runs in 765ms.
from enigma import (irange, concat, rev, div, is_square, is_prime, peek, printf) # split the string of digits at <k> and do the reverses of the # two sides satisfy fn1 and fn2? # if so, return the numbers as (n2, n1) def check(ds, k, fn1, fn2): (n1, n2) = (int(rev(ds[:k])), int(rev(ds[k:]))) if fn1(n1) and fn2(n2): return (n2, n1) # choose number of overs bowled (= O) for O in irange(1, 99): if O % 10 == 0: continue # no zeros # number of maiden overs (= M) for M in irange(1, min(O, 9)): # number of wickets taken (= W) for W in irange(2, 9): # number of runs conceded (= R) < 6 * O for R in irange(1, 6 * O - 1): # form the bowling analysis b = concat(O, M, R, W) if '0' in b: continue # can it be read (from right to left) as a square followed by # a prime, both having the same number of digits k = div(len(b), 2) if k is None or k < 3: continue r1 = check(b, k, is_prime, is_square) if r1 is None: continue # can it also be read (from right to left) as a prime followed by # a square with more digits rs = (check(b, j, is_square, is_prime) for j in irange(k + 1, 2*k - 2)) r2 = peek((r for r in rs if r is not None), default=None) if r2 is None: continue # output solution printf("b={b}, (sq, pr) = {r1}, (pr, sq) = {r2} [O={O} M={M} R={R} W={W}]")Solution: Tom’s bowling analysis is: 14-2-67-6.
Concatenating the digits working from right to left gives 676241, and this can be split as:
LikeLike
Jim Randell 8:49 am on 21 June 2026 Permalink |
By considering the number of digits in the constituent parts, we can show that the bowling analysis must be 6 digits, and therefore splits are 3:3 and 2:4. And this allows a straightforward solution.
The following run file executes in 79ms (and has an internal runtime of 765µs).
LikeLike
Ruud 10:42 am on 21 June 2026 Permalink |
It is obvious that the length of the numbers combined can’t be 4 as that can’t be divided into two parts which are not the same length and have more than one digit. Therefore, the length has to 6 and the sublength will be 3-3 and 2-4. Then it is just brute force:
import peek import istr for o, m, w in istr.product(range(1, 100), range(1, 10), range(2, 11)): for r in istr.range(6 * o): if ( "0" not in (omrw_reversed:= (omrw := istr("=omrw")).reversed()) and len(omrw_reversed) == 6 and omrw_reversed[:3].is_square() and omrw_reversed[3:].is_prime() and omrw_reversed[:2].is_prime() and omrw_reversed[2:].is_square() ): peek(omrw, omrw_reversed, o, m, r, w)LikeLike
Frits 10:44 am on 21 June 2026 Permalink |
Less brute force.
from enigma import is_prime # O-M-R-W should have an even number of digits, M and W are both single digits # so O and R must both have the same number of digits # O-M-R-W must have at least 6 digits as prime number followed by a perfect # square number containing more digits (both no single digis) # thus O and R are both 2-digit numbers # O-M-R-W = t_o, u_o, m, t_r, u_r, w # squares in range 100-9999 with no zeroes sqs = {n2 for n in range(11, 100) if '0' not in str(n2 := n * n)} # runs, first digit must also be the end digit of a square for t_r in (1, 4, 5, 6, 9): # second digit must also be the end digit of a prime for u_r in (1, 3, 7, 9): sr = str(r := 10 * t_r + u_r) # wickets for w in range(2, 10): rw = sr + (sw := str(w)) # a perfect square followed immediately by a prime if not int(wr := rw[::-1]) in sqs: continue # also as prime number followed by a perfect square if not is_prime(int(wr[:2])): continue # overs, first digit of o must be: # 1, 3, 7, or 9 and also the end digit of a square (0, 1, 4, 5, 6, 9) for t_o in (1, 9): for u_o in range(1, 10): if r >= 6 * (o := 10 * t_o + u_o): continue so = str(o) # maidens for m in range(1, 10): omrw = so + str(m) + rw rtol = omrw[::-1] # prime number followed by a perfect square if not int(rtol[2:]) in sqs: continue # also a perfect square followed immediately by a prime if not is_prime(int(rtol[3:])): continue print(f"answer: {o}-{m}-{r}-{w}")LikeLike
Alex.T.Sutherland 3:47 pm on 24 June 2026 Permalink |
Method:-
I concentrated on what was the 6 digit number particularly the 3d square.
If the following constraints are placed on the set of 3d squares there is only
one square left.
(No zeros,first 2 digits make a 2d prime,first digit > 1].
The third digit of this unique 3d square is now the starting digit of the 4d square.
The set of 4d numbers (approx 5 or 6) with the known starting number is tested
for no zeros and that the following 3 digits form a 3d prime.
There is only one answer .Hence the complete 6 digit number is now known.
The 6d number is segmented into a pattern of 2,1,2,1 to give O,M,R,W;
The answer to OMRW satisfies the constraints.
My answer has :- sum of the 6d-number digits = 26. R/O ~ 4.8.
Time : < 6ms
LikeLike