From The Sunday Times, 5th October 1980 [link]
Joe decided to utilise the garden see-saw to demonstrate the principles of balance, and of moments to, his family. Alf, Bert, Charlie, Doreen, Elsie and Fiona weighed 100, 80, 70, 60, 50 and 20 kilos respectively. The seesaw had three seats each side, positioned 1, 2 and 3 metres from the centre.
They discovered many ways of balancing using some or all of the family.
In one particular combination, with at most one person on each seat, one of the family not on the seesaw observed that the sum of the moments of all of the people on the seesaw was a perfect square.
“That’s right”, said Joe, “but, as you can see, it doesn’t balance — and what’s more, there’s nowhere you can sit to make it balance”.
“Wrong”, was the reply. “I could sit on someone’s lap”.
“True,” said Joe, “but only if you sit at the end”.
Which two would then be sitting together, and who else, if anyone, would be on the same side of the see-saw?
[To find the moment due to each person, multiply their distance from the centre by their weight. The sum of the moments on one side should equal the sum of those on the other if balance is to be achieved].
This puzzle is included in the book The Sunday Times Book of Brainteasers (1994).
[teaser950]
Jim Randell 5:08 pm on 13 June 2024 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.It runs in 77ms. (Internal runtime of the generated program is 230µs).
Solution: Sam’s number was: 143968275.
LikeLike
Ruud 7:49 pm on 15 June 2024 Permalink |
No a priori knowledge, just brute force:
from istr import istr for i in istr.concat(istr.permutations(istr.digits("1-"), 9)): if ( i[1] == i[0] + i[2] and i[3] == i[2] + i[4] and i[5] == i[4] + i[6] and i[7] == i[6] + i[8] and i.divisible_by(11) and i.divisible_by(i[0]) and i.divisible_by(i[8]) ): print(i)Note that this requires the latest-soon to be published- version of istr.
LikeLike
GeoffR 6:56 pm on 13 June 2024 Permalink |
LikeLike
Frits 7:01 pm on 13 June 2024 Permalink |
LikeLike
Frits 9:23 pm on 13 June 2024 Permalink |
You only need to know three digits (like the 1st, 3rd and 5th digits).
from functools import reduce # convert digit sequences to number d2n = lambda s: reduce(lambda x, y: 10 * x + y, s) dgts8 = set(range(1, 9)) dgts9 = dgts8 | {9} for C in dgts8: for E in dgts8 - {C}: # 11 divisibility rule G = (11 if C + E < 11 else 22) - (C + E) D, F = C + E, E + G # different digits if len(r1 := dgts9 - {C, E, G, D, F}) != 4: continue for A in r1: B = A + C if len(r2 := sorted(r1 - {A, B})) != 2: continue H, I = r2[1], r2[0] if H != G + I: continue ABCDEFGHI = d2n([A, B, C, D, E, F, G, H, I]) if ABCDEFGHI % A: continue if ABCDEFGHI % I: continue print("answer:", ABCDEFGHI)LikeLike
Ruud 6:44 am on 16 June 2024 Permalink |
This version does not require the divisible_by method:
from istr import istr for i in istr.concat(istr.permutations(istr.digits("1-"), 9)): if i[1] == i[0] + i[2] and i[3] == i[2] + i[4] and i[5] == i[4] + i[6] and i[7] == i[6] + i[8] and i % 11 == 0 and i % i[0] == 0 and i % i[8] == 0: print(i)LikeLike