Teaser 3156: Balancing act
From The Sunday Times, 19th March 2023 [link] [link]
A circus elephant standing on one end of a see-saw pivoted at the centre was balanced by a troupe of fewer than 20 acrobats, each of equal weight, standing on the other end. The elephant moved forwards and several acrobats jumped off to maintain balance. The elephant moved backwards and some of them climbed back on to the end to rebalance.
The elephant always moved a prime number of feet and there was always a prime number of acrobats on the see-saw. If I told you how far backwards the elephant moved you could work out the numbers of acrobats.
(In equilibrium, the product of weight and distance from pivot point must be the same on both sides).
How far did the elephant move backwards, and how many acrobats are there in the troupe?
[teaser3156]
Jim Randell 5:24 pm on 17 March 2023 Permalink |
I think it is necessary to assume that the elephant did not return to its original position. (i.e. “some of them” is interpreted as “some (but not all) of them”).
So we suppose that we start off with a see-saw of length 2d and a unit weight acrobats on one end (a is a prime number, less than 20). They are balanced by an elephant of weight a on the other end.
The elephant then moves forwards (towards the pivot) p feet (p is a prime number), and some of the acrobats jump off, leaving b acrobats balancing the elephant (b is a prime number, less than a):
The elephant then moves backwards (away from the pivot) q feet (q is a prime number, less than p), and some of the acrobats remount to make c acrobats balancing the elephant (c is a prime number, between b and a):
From these two equations we can determine p in terms of q and a, b, c:
There are only a certain number (a, b, c) values, so we can look at possible values for q, and see if there is only a single set of (a, b, c) values that give a viable value of p.
This Python program runs in 62ms. (Internal runtime is 285µs).
Run: [ @replit ]
from enigma import (primes, subsets, div, inf, fdiv, printf) # collect possible (a, b, c) numbers of acrobats abcs = list((a, b, c) for (b, c, a) in subsets(primes.between(2, 20), size=3)) # consider the distance the elephant moves back = q for q in primes.irange(2, inf): # find viable p values ps = list() for (a, b, c) in abcs: p = div(q * (a - b), c - b) if p and p > q and p in primes: ps.append((a, b, c, p)) if len(ps) == 1: (a, b, c, p) = ps[0] printf("q={q} -> a={a} b={b} c={c} p={p}; d={d:g}", d=fdiv(a * q, c - b)) breakSolution: The elephant moved backwards 11 ft. There are 19 acrobats in the troupe.
The see-saw is 19 feet either side of the pivot (i.e. end to end length is 38 feet).
And initially there are 19 acrobats on one end, balanced by an elephant that weighs the same as 19 acrobats on the other end.
The elephant moves forward by 17 ft, so it is 2 ft from the pivot, and this is balanced by 2 acrobats 19 ft from the pivot (19 × 2 = 2 × 19).
The elephant then moves backwards by 11 ft, so it is 13 ft from the pivot. And this is balanced by 13 acrobats 19 ft from the pivot (19 × 13 = 13 × 19).
There are 16 candidate solutions.
So the answer is found from q = 11.
LikeLike
Jim Randell 11:53 am on 18 March 2023 Permalink |
Even shorter (and exhaustive):
and both p and q are primes, so can be determined from their ratio.
Run: [ @replit ]
from enigma import (primes, subsets, fraction, filter_unique, item, fdiv, printf) # generate candidates (p, q, a, b, c) def candidates(): for (b, c, a) in subsets(primes.between(2, 20), size=3): (q, p) = fraction(c - b, a - b) if primes.is_prime(q) and primes.is_prime(p): yield (p, q, a, b, c) # find solutions unique by q (= item 1) for (p, q, a, b, c) in filter_unique(candidates(), item(1)).unique: printf("q={q} -> a={a} b={b} c={c} p={p}; d={d:g}", d=fdiv(a * q, c - b))LikeLike
Jim Randell 8:27 am on 18 March 2023 Permalink |
@GeoffR: I think 5 is also a prime.
And there are additional candidate solutions where the length of the see-saw is not an even integer number of feet. But the length of the see-saw can be eliminated from the equations to keep the remaining variables integers. (Although it would be possible to also specify the see-saw length as an integer number of inches).
LikeLike
GeoffR 10:00 am on 18 March 2023 Permalink |
from itertools import permutations from enigma import is_prime from collections import defaultdict nums = defaultdict(list) primes = (2, 3, 5, 7, 11, 13, 17, 19) for acrobats in permutations(primes, 3): # A1 = full acrobat troupe # A2 = acrobats after elephant moves forward # A3 = acrobats after elephant then moves backwards A1, A2, A3 = acrobats if A1 > A2 and A1 > A3 and A2 < A3: # for intial balancing of elephant v. troupe # elephants weight = weight of acrobat troupe E = A1 # assume max. half seesaw length = 25 ft. for dist in permutations(range(1, 26), 3): half_see_saw, p1, p2 = dist if p2 < p1 and is_prime(p1) and is_prime(p2): # Taking moments about centre pivot if (half_see_saw - p1) * E == half_see_saw * A2: if (half_see_saw - p1 + p2) * E == half_see_saw * A3: # index dictionary on distance elephant moved backwards nums[p2] += [(p1, p2, A1, A2, A3)] # find a single solution for k,v in nums.items(): if len(v) == 1: print(f"Distance elephant moves backward = {k} ft.") print(f"Number of acrobats in troupe = {v[0][2]}.")LikeLike