好土同志, on 12 April 2010 - 01:39 PM, said:
I mentioned the gold bar question at lunch as sort of comparison, and of course everyone at the table all got excited. Now I have to give them the answer. Except that I had forgotten it.
So, if I recall correctly, you have 100 bars of gold. One of them is lighter than the rest. You have one scale, and you can use it 3 times. Find out which gold bar is the light one.
Anyone got the solution memorized? Or know of a link? My GoogleFu is failing me on this one.
I have not heard of it before, but three weighings seems too few unless I'm missing a trick.
I would have guessed that the solution is to treat it as a trinary problem rather than binay, thereby reducing the number of weighings:
- binary would be to put half of the 100 bars on either side of the scales, identify the lighter half and use recursion on that half. This is the obvious approach.
- trinary would be to put a third of the 100 bars on either side of the scales and leave the last third off. Either the scales are uneven (identify which is lighter) or else perfectly even (the unweighed third contains the light bar).
In that trinary model
1st weighing: 33 vs 33 (34 aside), worst case outcome: the light bar is in the 34
2nd weighing: 11 vs 11 (11 or 12 aside), worst case outcome: the light bar is in the 12
3rd weighing: 4 vs 4 (3 or 4 aside), worst case outcome (and most likely): the light bar is in the 4
4th weighing: 1 vs 1 (2 aside) ~50% chance of finishing here, else
5th weighing: 1 vs 1 definitely finish here
#trials = n^(1/m). Setting m as 3 rather than 2 makes a geometric improvement in the #trials. For n=100, m=3 => #trials=4.64 (instead of 10 for m=2).
Is there another trick to further reduce the weighings?