Sunday Times Brain-Teaser 696 – The Browning Version
by J E Kessel and J R Partridge
From The Sunday Times, 17th November 1974
You see, Inspector, the combination of my safe is a six-figure number. In case anyone needed to get into it while I was away, I gave each of my clerks (Atkins, Browning and Clark) one of the two-figure numbers which make up the combination. I also told each the position in the combination of the number of another clerk, but not the number itself.
Browning must have overheard me telling a friend that it is a coincidence that two of these numbers are squares and if you put them together you get a four-figure number that equals the other clerk’s number squared. I remember I also said something about whether or not the combination is divisible by this clerk’s number.
When he was caught, Browning said, “I can’t understand why the alarm went off; I know Clark’s is the first number”. I later realised that what I’d told my friend about whether or not that other number was a factor was wrong, which was lucky for me as Browning had got his own number in the right place.
What was the combination?
-
Brian Gladman permalink1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859from itertools import permutationsfrom collections import defaultdict# find three two-digit numbers s1, s2 and s3# such that s1^2 = 100.s2^2 + s3^2nts, sqrs = [], set(i * i for i in range(4, 10))for s1 in range(32, 100):t = s1 * s1s2, s3 = t // 100, t % 100if {s2, s3} < sqrs:nts.append((s1, s2, s3))# for mapping B's knowledge to possible solutions# when his belief that the combination divides by# the first number is right/wrong respectivelyb2sr = defaultdict(list)b2sw = defaultdict(list)# consider all two-digit triplesfor n3 in nts:# map the three numbers to the three clerks A, B and Cfor p in permutations(n3):# put A, B and C's numbers in their positions in# the combination (with C always first)for q in ((p[2], p[0], p[1]), (p[2], p[1], p[0])):# B knows his/her number and (thinks he/she) knows that# the combination is divisible the first number; hence# save the solutions indexed on these two 'knowns' when# the belief is both right (b2sr) and wrong (b2sw)comb = (100 * (100 * q[0] + q[1]) + q[2])divisible = (comb % n3[0] == 0)t = (n3[0], str(comb))b2sr[(p[1], divisible)].append(t)b2sw[(p[1], not divisible)].append(t)# consider solutions that allow B to deduce the combination# based on what he/she knows and believes; do this when the# belief is both right and wrongsolr, solw = set(), set()for b2s, sol in ((b2sr, solr), (b2sw, solw)):for (b, belief) in b2s.keys():(n, comb), *r = b2s[(b, belief)]if not r:# but their guess failed even though their number's position# in the combination was guessed correctly; hence the other# two numbers in the combination need to be exchangedx, y, z = (comb[i:i+2] for i in (0, 2, 4))comb = int(z + y + x if b == int(y) else y + x + z)sol.add(comb)# check that the solution is the same irrespective# of the truth of what B overhearsif solr == solw:print(f"Combination = {solr.pop()}")