Jun 29, 2007 -- posted by TechMonk

## Puzzle 1 : Take a chill pill!

This is one of the Microsoft interview questions, should be easier to answer as writing a code is not required.

“You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?”

By scale I mean a digital weight measuring machine.

SOLUTION:

1. Mark the jars with numbers 1, 2, 3, 4, and 5.

2. Take 1 pill from jar 1, take 2 pills from jar 2, take 3 pills from jar 3, take 4 pills from jar 4 and take 5 pills from jar 5.

3. Put all of them on the scale at once and take the measurement.

4. Now, subtract the measurement from 150 ( 1*10 + 2*10 + 3*10 + 4*10 + 5*10)

5. The result will give you the jar number which has contaminated pill.

Hi

Now to make it little complex. Consider the same situation with 10 jar with 10 pills…

We can have same solution. But here we can also have alternate solution…

Think….

Regads

Navin

The idea is to form a different weight set from each jar in by picking consecutive numbers from each jar and weighing. If I got 149 then first jar is the one, if I got 148 then the second jar and so on.

Oh Sorry…. I posted in the wrong article

Can i use binary operators in my solution??

good one.. I never got it correct

I have added the answer to the main post. Congratulations to Fiery and Arindam for getting it right.

answer is?

correct answer arindam

Well this is my solution…..I do not know how to hide this ( tell me someone)

Solution Hidden

Well I hope this is correct…..

Kanishk this is a nice thing u have started…..

Fiery got it correct. Thanks for hiding it. Let us see others coming up with the same.

This was a simple one i guess!

Solution Hidden