You have 4 jars of pills. Each pill is a certain weight, except for contaminated pills contained in one jar, where each pill is weight + 1. How could you tell which jar had the contaminated pills in just one measurement?
The Solution
We have to assume a unit weight of one for uncontaminated pills to solve this. Take one pill from the first jar, two pills from the second, three pills from the third and four pills from the fourth. You now have ten pills. Put all ten pills on a scale. Subtract ten from the weight and you have the number of the jar with poison pills.
I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods. Read more »
Four Jars of Pills
The Problem
You have 4 jars of pills. Each pill is a certain weight, except for contaminated pills contained in one jar, where each pill is weight + 1. How could you tell which jar had the contaminated pills in just one measurement?
The Solution
We have to assume a unit weight of one for uncontaminated pills to solve this. Take one pill from the first jar, two pills from the second, three pills from the third and four pills from the fourth. You now have ten pills. Put all ten pills on a scale. Subtract ten from the weight and you have the number of the jar with poison pills.