Brain-Teaser 501: [Missing weight]
From The Sunday Times, 10th January 1971 [link]
The grain retailer had with his scales a set comprising the smallest number of weights which, use in any way required, enabled him to weigh loads of every exact number of kilos from 1 to 40 kilos.
One day he mislaid one of his weights and, remembering that the rival shop next door had had an identical set which was no longer in use, he asked to borrow it.
That set too, however, proved to have one of its weights missing, and so it turned out that, even with all the surviving weights in both sets at his disposal, he could weigh only 25 different loads within the required range of 1-40 kilos.
What was the retailers missing weight?
This puzzle was originally published with no title.
[teaser501]
Jim Randell 9:53 am on 19 September 2019 Permalink |
In Brainteaser 1575 we determined that a set of weights consisting of the first four powers of three (1, 3, 9, 27) will allow us to weigh all integer amounts between 1 and 40.
The borrowed set must be missing the same weight as the original set (otherwise he could just replace the missing weight and weigh 1 … 40 kg again). So there are only 4 options to try.
This Python program runs in 95ms.
from enigma import (irange, subsets, printf) # set of weights for weighing 1 ... 40 kg weights = (1, 3, 9, 27) # find values that cannot be weighed with the set of weights def values(weights): # desired values ws = set(irange(1, 40)) # choose a subset of the weights for s in subsets(weights): # choose a pan for each weight for p in subsets((+1, -1), size=len(s), select="M"): w = sum(x * y for (x, y) in zip(s, p)) ws.discard(w) return ws # choose 3 of the 4 weights for ws in subsets(weights, size=3): # determine the number of missing values using 2 sets of weights vs = values(ws * 2) # if there 15 missing values... if len(vs) == 15: # output solution printf("{ws} -> {vs}")Solution: The missing weight is 9 kg.
Both sets are missing the 9 kg weight, and there are 15 values that cannot be weighed (9 – 18 kg, 36 – 40 kg).
If both the 1 kg weights are missing there are 27 values that cannot be weighed (1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40).
If both the 3 kg weights are missing there are 18 values that cannot be weighed (3 – 6, 12 – 15, 21 – 24, 30 – 33, 39 – 40)
If both the 27 kg weights are missing there are 14 values that cannot be weighed (27 – 40).
LikeLike