Saturday, October 13, 2012

Five Jars of Pills.

The previous post  reminded me of another puzzle.

Lets say there are 5 jars of pills. One of the 5 jars contains contaminated pills. All pills weigh 10 grams, except contaminated pills. contaminated pills weigh 20 grams. Lets say you are given a scale / spring balance, which can give you the weight measurement, Whats the least number of measurements you need to find out the jar with contaminated pills.

.
.
.
.
.
.
.
.

Solution : Most people try to solve the problem, similar to the well known puzzle, but there is key difference here. Here, we have spring balance and not simple balance, hence we can not use principle of equality for elimination.

Well, the answer is 1, and is based on simple math. Here's how. Label the jars as Jar1, Jar2, Jar3, Jar4, Jar5

Take 1 pill from 1st jar, 2 pills from 2nd jar, 3 pills from 3rd jar, 4 pills from 4th jar and 5 pills from 5th jar and measure the total weight of 1+2+3+4+5 i.e. 15 pills.

If the measurement is

160 grams then the contaminated pill is from Jar 1 [ 20 + (2 * 10) + (3 * 10) + (4 * 10) + (5 * 10) = 160 ]
170 grams then the contaminated pill is from Jar 2 [ 10 + (2 * 20) + (3 * 10) + (4 * 10) + (5 * 10) = 170 ]
180 grams then the contaminated pill is from Jar 3 [ 10 + (2 * 10) + (3 * 20) + (4 * 10) + (5 * 10) = 180 ]
190 grams then the contaminated pill is from Jar 4 [ 10 + (2 * 10) + (3 * 10) + (4 * 20) + (5 * 10) = 190 ]
200 grams then the contaminated pill is from Jar 5 [ 10 + (2 * 10) + (3 * 10) + (4 * 10) + (5 * 20) = 200 ]


Think about the variation : What if you just know contaminated pills are of different weight, but do not know whether they are overweight or underweight.

No comments: