This is a pretty popular brain teaser with many companies.
On the shelf you have 10 identical bottles of identical pills (let’s say there’s a hundred pills in each bottle). However, one of those 10 bottles contains cheap knockoff pills. The only way to differentiate fake pills from real pills is the weight - while real pills weigh 1 g each, the knockoff pills are only 0.9 g. You have one scale that shows the exact weight (down to the mg) of whatever is weighed.
How can you tell which bottle contains fake pills with just 1 weighing?
Answer: Take 1 pill from the first bottle, 2 pills from the second bottle, 3 pills from the third bottle, and so on. Ideally you would have 55 pills weighing 55 grams, when you put the entire pile of pills on the weighing scale.
However, that won’t be the case, since some pills are only 0.9 g. The deviation from 55 g would tell you which bottle contains the fake pills. If you’re off by 0.9 g, it must have been the first bottle, if you’re off by 1.8 g, it must have been the second bottle, and so on.
18 Comments on 10 bottles of pills
Correcting this last line :
“If you’re off by 0.9 g, it must have been the first bottle, if you’re off by 1.8 g, it must have been the second bottle, and so on. ”
Should be:
“If you’re off by 0.1 g, it must have been the first bottle, if you’re off by 0.2 g, it must have been the second bottle, and so on.”
Just a better way of putting the solution, thought to post it:
1) Lets name the bottles 1,2,3 .. 10
2) Take out i number of pills from the i-th bottle. So we will take out 1 pill from 1st bottle, 2 pills from 2nd bottle, 3 pills from 3rd bottle and so on..
3) Now weigh the collected pills. If the weighning in grams have decimal place x, then the (10-x)th bottle has the bad pills.
what if each bottle has only 1 pill?
what if all the bottles have same pills?and what will be the case if we ppick up randomly?
Boys and Girls,
For this kind of puzzle always think Binary Search!
Regards.
hey,
The best as of yet…we have 10 bottles with 100 pills in each of them….and we have a scale which is 100% accurate which is unrealistic but given in the question.
5 bottles on one side of scale and 5 on the other.
heavy one goes down discard the other 5 bottles….and compare with other bottles and so on.
easiest way to do this problem is to place 1st bottle on scale(each bottle should weigh 100grams plus bottle weight. then place each additional bottle on scale one by one, if second bottle placed on scale adds more weight than the original first bottle then the first bottle is bad, if second bottle doubles the wieght exactly then keep adding bottle until the bad bottle adds less weight than the good bottles, this way you dont have to take out 55 different pills from all the bottles and risk the chance of getting your pills mixed up
Follow procedure as in comment 2 of this discussion. however from ith bottle remove i*10 pills instead of i. this way total would be 550 and the difference between 550 and sum of pills in all bottles would actually reveal the bottle number directly.
wassup!
good luck
rocky
pilot said,(Not correct)
One thing there is limit to weigh, other 5 on either side make 5 bottle to discard, but after we can’t weigh 2 1/2 and 2 1/2 on either side. Because 3 + 2 wiegt doesn’t give accurate answer.
I feel What Pilot said is almost the most easiest way.
Here’s hw I elaborate it.
10 bottles have say 10 pills each of them.Cheap pills are 0.9 gms each and real pills are 1 gms each.
So, divide 10 bottles into half i.e. 5 each and weight them, one of them will be lighter.
Now take the lighter one(5 bottles) n divide them as 2 and 3 and weigh them, one of them will be lighter, So take the lighter one (cheap pills maybe in the 2 mottles or 3 bottles) again divide appropriately, you will arrive at the final result.
err, the questions says weighing scale, not a balance. i.e. the instrument is used to measure weight and has only “one side”; it’s not a two-sided instrument used to tell which side is heavier.
Most of you are conveniently making the problem easier by forgetting that you’re only given ONE opportunity to use the scale.
Binary searching requires multiple iterations, which by definition violates the fundamental premise of this puzzle.
You should understand both solutions: the mathematical one as well as the binary search. What will you do if your interviewer insists that you solve this problem the correct way?
Remeber, the constrain in the problem - you can make just one weighting. So some of the guys have given the answer above, let me repeat it again.
Take 1 pill from bottle no. 1, 2 pills from bottle no. 2, … 5 pills from bottle no. 5.
Now there are total of 15 pills. Weight these 15 pills together at once. Let the weight is x gm.
If all those pills were non-defective, i.e. each would weight 1 gm, so there would be 15 gm. But there are some defective (unknown number) of pills which each weights 0.9 gm. So obiviously, this weight with some defective pills is less than 15 gms, and the difference is (15 - x) gms.
This differences is contributed by the defective pills. If this difference is .1, there are one defective pills (bottle no. 1 defective). If the difference is .2 gms, there were 2 defective pills( bottle no. 2 defective).. and so on.
More puzzle? let me know…
I agree with Gururajh’s explanation, One thing there is limit to weigh, other 5 on either side make 5 bottle to discard, but after we can’t weigh 2 1/2 and 2 1/2 on either side. Because 3 + 2 weight doesn’t give accurate answer for the 1/2’s….:-)
Y.S.GURURAJ, there’s a ternary approach that is actually more efficient than the binary search.
In the example where you have 5 bottles left, pick 4 of them and weigh them 2 and 2. If they weigh the same amount, the 5th bottle is the knockoff. If they weigh different amounts, weigh just those two bottles.
For any number of bottles n, make 2 groups of floor(n/2) bottles, and 1 group of n%2 bottles, etc. So when n is even you’re binary searching, but when n is odd, you’re ternary searching.
Note that if you’re CERTAIN that one of the bottles have lighter pills, you can skip the pills from bottle #10, making do with 45 pills in total - a weight of 45 g would mean that bottle #10 is the lighter one. Less work fishing up pills.
(In practice, though, I’d stick with using 55 pills - you should always consider the possibility that the guy who brought the bottles messed up…)
Take a pill from each bottle(number them corresponding to the bottle it is taken from) and start placing one pill at a time on the scale. Since each pill weighs exactly 1 gm(except the knocfoo pill), the scale would read 1gm, 2 gm,…and so on. When the increase in not in multiple of 1 gm, you know you have the culprit pill and the bottle it is taken from.
Simple isn’t it?
Why are you all still answering this question? The answer was given with the question. You cannot weigh more than one time, which means all of your alternative answers are incorrect. Thie only thing wrong with the initial answer was that you would be off by .1 if it is bottle 1, .2 if it is bottle 2, and so on.
One of the main objectives of questions like this is to see if you can listen to requirements and find an answer that fits all of the requirements, not just a couble of them.