Brain-Teaser 889: Counting the hours
From The Sunday Times, 20th August 1978 [link]
At school the other day, little Johnny was working with one of those boards with twelve clock-points regularly spaced round a circle against which should be put twelve counters showing the hours.
He was, in fact, in a bit of a daze about the whole thing and the only hour he was absolutely dead sure of was 12 whose counter he correctly placed. As for the eleven others, if the truth be told, he just put them around at random.
But Jill, his teacher, spotted some curious things. She first noticed that, however she chose a quartet of counters which formed the corners of a square, their sum was always the same.
Next, she saw that if she formed numbers by multiplying together the counters at the corners of each square, one of those numbers was more than six times one of the others.
She also observed that the counters in each quartet were, starting at the lowest, in ascending order of magnitude in the clockwise direction, and that 12 was not the only correct counter.
In break, she reported all this to her colleague, Mary, adding “If I were to tell you, in addition, how many hours apart from the 12 Johnny had got right, you could tell me which they were”.
Which were they?
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 1 (1980). The puzzle text above is taken from the book.
[teaser889]
Jim Randell 10:01 am on 7 December 2021 Permalink |
There are three squares that can be constructed, using the numbers in positions (12, 3, 6, 9), (1, 4, 7, 10), (2, 5, 8, 11). These partition the 12 numbers into 3 sets of 4.
The total sum of the numbers is T(12) = 78, so values for each set must sum to 78/3 = 26.
The following Python program runs in 48ms. (Internal runtime is 680µs).
Run: [ @replit ]
from enigma import (irange, subsets, diff, ediv, tuples, multiply, cproduct, filter_unique, unpack, printf) # find viable layouts def generate(): ns = list(irange(1, 12)) T = sum(ns) t = ediv(T, 3) # choose 3 numbers to go with 12 (and they must be in ascending order) n12 = 12 for (n3, n6, n9) in subsets(diff(ns, [n12]), size=3): s1 = (n3, n6, n9, n12) if sum(s1) != t: continue p1 = multiply(s1) # choose numbers for (1, 4, 7, 10) for s2 in subsets(diff(ns, s1), size=4): if sum(s2) != t: continue p2 = multiply(s2) # remaining numbers s3 = diff(ns, s1 + s2) p3 = multiply(s3) # one of the products must be more than 6 times one of the others if not (max(p1, p2, p3) > 6 * min(p1, p2, p3)): continue # assign s1 to (1, 4, 7, 10) and s2 to (2, 5, 8, 11) fn = lambda s: tuples(s, 4, circular=1) for ((n1, n4, n7, n10), (n2, n5, n8, n11)) in cproduct([fn(s2), fn(s3)]): # construct the arrangement vs = [n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12] # find the numbers in the correct positions ss = tuple(n for (i, n) in enumerate(vs, start=1) if i == n) # there should be more than 1 if len(ss) > 1: yield (vs, ss) # knowing len(ss) allows you to determine ss r = filter_unique(generate(), unpack(lambda vs, ss: len(ss)), unpack(lambda vs, ss: ss)) # output solutions for (vs, ss) in r.unique: printf("{vs} -> {ss}")Solution: Johnny also placed 4 and 10 in the correct positions (as well as 12).
There are two positions that lead to this:
They both have squares with values (1, 2, 11, 12), (3, 4, 9, 10), (5, 6, 7, 8). But in the second one the (5, 6, 7, 8) square is rotated through 180°.
The sums of the squares are all 26, and the products are (264, 1080, 1680), and 1680 > 1584 = 6 × 264.
We find there are 14 possible arrangements that give the situation described.
10 of them have 12 plus either 5, 7, or 8 in the correct position.
2 of them have 12 plus (4, 5, 10) or (4, 8, 10) in the correct position.
And the remaining two are those shown above with 12 plus (4, 10) in the correct position.
LikeLike
Frits 9:22 am on 8 December 2021 Permalink |
@Jim, you also could have used decompose() to find 4 numbers which sum to “t”.
LikeLike
GeoffR 7:50 pm on 7 December 2021 Permalink |
# four square group positions are (12,3,6,9), (1,4,7,10), (2,5,8,11) # sum of digits (1-12) = 78, so sum of each group is 26 hours = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) H12 = 12 # set correct counter for Hour 12 from itertools import permutations # 1st square group positions (12,3,6,9) for p1 in permutations(hours, 3): # counters for hours H3, H6 and H9 H3, H6, H9 = p1 if H3 + H6 + H9 + H12 != 26:continue if not (H3 < H6 < H9 < H12):continue q1 = hours.difference([H3, H6, H9]) # 2nd square group positions (1,4,7,10) for p2 in permutations(q1, 4): # counters for hours H1, H4, H7, H9 H1, H4, H7, H10 = p2 if H1 + H4 + H7 + H10 != 26:continue if not (H1 < H4 < H7 < H10):continue q2 = hours.difference(p1).difference(p2) # 3rd square group positions (2,5,8,11) for p3 in permutations(q2,4): # counters for hours H2, H5, H8, H11 H2, H5, H8, H11 = p3 if H2 + H5 + H8 + H11 != 26:continue if not (H2 < H5 < H8 < H11):continue # find multiples of the corners of three groups m1 = H3 * H6 * H9 * H12 m2 = H1 * H4 * H7 * H10 m3 = H2 * H5 * H8 * H11 m1, m3 = min([m1, m2, m3]), max([m1, m2, m3]) if m1 < m2 < m3: # check one multiple is more than 6X another multiple if m2 > 6 * m1 or m3 > 6 * m1: print(f" Three products are {m1}, {m2}, and {m3}.") print(f" (H1, H2, H3) = ({H1}, {H2}, {H3})") print(f" (H4, H5, H6) = ({H4}, {H5}, {H6})") print(f" (H7, H8, H9) = ({H7}, {H8}, {H9})") print(f" (H10, H11, H12) = ({H10}, {H11}, {H12})") # Three products are 264, 1080, and 1680. # (H1, H2, H3) = (3, 5, 1) # (H4, H5, H6) = (4, 6, 2) # (H7, H8, H9) = (9, 7, 11) # (H10, H11, H12) = (10, 8, 12) # Only counters for hours 4, 10 and 12 are in the correct position.LikeLike
GeoffR 9:21 am on 8 December 2021 Permalink |
LikeLike
Sunday Times Brain-Teaser 889 – Counting the Hours | PuzzlingInPython 9:58 am on 8 December 2021 Permalink |
[…] Published 20th August 1978 (link) […]
LikeLike