Teaser 1984: Which whatsit is which?
From The Sunday Times, 24th September 2000 [link]
I have received three boxes of whatsits. They all look alike but those in one of the boxes weigh 6 grams each, those in another box all weigh 7 grams each, and all those in the remaining box weigh 8 grams each.
I do not know which box is which but I have some scales which enable me to weigh accurately anything up to 30 grams. I with to use the scales to determine which whatsit is which.
How can I do this with just one weighing?
The text of this puzzle is taken from the book Brainteasers (2002), the wording differs only slightly from the puzzle originally published in the newspaper.
The following note was added to the puzzle in the book:
When this Teaser appeared in The Sunday Times, instead of saying “some scales” it said “a balance”. This implied to some readers that you could place whatsits on either side of the balance — which opens up all sorts of alternative approaches which you might like to think about.
There are now 400 Teaser puzzles available on the site.
[teaser1984]
Jim Randell 9:45 am on 13 December 2020 Permalink |
Evidently we need to find some selection from the three types of whatsit, such that from the value of their combined weight we can determine the weights of the individual types.
If the scale did not have such a low maximum weight we could weigh 100 type A whatsits, 10 type B whatsits, and 1 type C whatsit, to get a reading of ABC, which would tell us immediately the weights of each type. (For example, if the total weight was 768g, we would know A = 7g, B = 6g, C = 8g).
We first note that if we can determine the weights for two of the types, then the third types weight must be the remaining value. (Equivalently if the selection (a, b, c) determines the weights, so does selection (0, b − a, c − a) where a is the smallest count in the selection).
So we need to find a pair of small numbers (as 6 or more of the lightest whatsits will give an error on the scales), that give a different outcome for each possible choice of whatsits.
This Python program runs in 45ms.
Run: [ @repl.it ]
Solution: You should choose one whatsit from one of the boxes, and three whatsits from another box.
The combined weight indicates what the weight of each type of whatsit is:
LikeLike
Frits 12:01 pm on 13 December 2020 Permalink |
LikeLike
Frits 12:17 pm on 13 December 2020 Permalink |
I could have used “[X, Y, Z].count(0) == 1” but somehow count() is below my radar (probably because I have read that count() is/was quite expensive).
LikeLike