From The Sunday Times, 18th April 1982 [link]
The Manager of a large company greeted his twelve new computer staff. “You have been given consecutive, five-digit, Staff Reference Numbers (SRN). I remember numbers by finding their prime factors, using mental arithmetic — pre-computer vintage. Why not try it? If you would each tell me what factors you have, without specifying them (and ignoring unity), I should be able to work out your SR numbers”.
John said: “My number is prime.”
Ted said ” I have two prime factors. Your number follows mine doesn’t it, Les?”
Ian said: “I also have two, one of which squared. Alan’s just before me on the list.”
Sam said: “One of mine is to the power four. The last two digits of my SRN give me the other prime factor.”
Pete said: “I’ve got one factor to the power four as well. The other one is my year of birth.”
Brian said: “My number has one prime factor cubed and two others, both squared.”
Chris said: “I’m the only one with four factors, one of which is squared. Fred’s number is one less than mine.”
Dave started to say: “Kevin’s SRN is the one after mine, which …” when the Manager interrupted. “I can now list all twelve!”
List the twelve people, by initials, in increasing order of SRNs. What is Sam’s SRN?
This was the final puzzle to go by the title “Brain teaser“. The next puzzle was “Brainteaser 1030“.
This puzzle is included in the book The Sunday Times Book of Brainteasers (1994).
[teaser1029]
Jim Randell 6:48 am on 6 July 2025 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.It runs in 78ms. (Internal runtime of the generated program is 279µs).
Run: [ @codepad ]
Solution: The square root is 661.
And so the 6-digit number is: 661^2 = 436921.
And we have:
LikeLike
GeoffR 10:17 am on 6 July 2025 Permalink |
% A Solution in MiniZinc include "globals.mzn"; var 1..9:a; var 1..9:b; var 1..9:c; var 1..9:d; var 1..9:e; var 1..9:f; var 316..999:ans; % square root of abcdef var 100000..999999: abcdef == 100000*a + 10000*b + 1000*c + 100*d + 10*e + f; constraint all_different([a, b, c, d, e, f]); constraint a + b + c + d + e + f == 5 * (a + f); constraint d > e /\ e > f; predicate is_sq(var int: c) = let { var 0..ceil(pow(int2float(ub(c)),(1/2))): z } in z*z = c; constraint ans * ans == abcdef; constraint is_sq(abcdef); solve satisfy; output["Square root of the six digit number = " ++ show(ans)];LikeLike
Frits 3:03 pm on 6 July 2025 Permalink |
# last 2 digits y and z (abcdef = xyz^2) last2 = set(i for i in range(11, 100) if i % 10 and 9 < (m := (i * i) % 100) < 90 and m // 10 > m % 10) for yz in last2: # A + F <= 7 so X < 9 for x in range(3, 9): xyz = 100 * x + yz abcdef = xyz * xyz if len(set(s := str(abcdef))) != 6: continue if s[3] <= s[4] or "0" in s: continue dgts6 = [int(x) for x in s] if sum(dgts6) != 5 * (dgts6[0] + dgts6[-1]): continue print("answer:", xyz)LikeLike
Frits 5:57 pm on 6 July 2025 Permalink |
Processing six-digit numbers to find a valid square root.
from enigma import is_square # last 2 digits e and f (abcdef = xyz^2) last2 = set(divmod(m, 10) for i in range(11, 100) if i % 10 and 9 < (m := (i * i) % 100) < 90 and m // 10 > m % 10) for (e, f) in last2: ef = 10 * e + f for d in range(e + 1, 10): _def = 100 * d + ef # 21 <= 5 * (a + f) <= 39 or 4 < a + f < 8 for a in set(range(max(1, 5 - f), 8 - f))- {d, e, f}: # remaining for b + c if not (3 <= (bc := 5 * (a + f) - (a + d + e + f)) <= 17): continue adef = 10**5 * a + _def # determine missing numbers x and y (x + y = bc with x < y) for x in set(range(max(1, bc - 9), (bc + 1) // 2)) - {a, d, e, f}: if (y := bc - x) in {a, x, d, e, f}: continue for b, c in ((x, y), (y, x)): n = adef + 10**4 * b + 10**3 * c if (xyz := is_square(n)): print("answer:", xyz)LikeLike
Ruud 4:22 pm on 6 July 2025 Permalink |
import math import istr for i in range(int(math.sqrt(100_000)), int(math.sqrt(1_000_000))): if (sum((sq := istr(i * i))) == 5 * (sq[0] + sq[-1])) and sq.all_distinct() and "0" not in sq and sq[-3] > sq[-2] > sq[-1]: print(sq, i)LikeLike
GeoffR 9:17 am on 9 July 2025 Permalink |
sq6 = [ n**2 for n in range(317, 1000) if len(set(str(n**2))) == 6 ] for num in sq6: ds = str(num) if '0' in ds: continue dig = [int(x) for x in ds] if (dig [3] > dig[4] > dig[5]): if sum(dig[:6]) == 5 * (dig[0] + dig[5]): print (f"Square root is {int(num ** 0.5)}.")LikeLike