Contaminated Pills Puzzle – Coding N Concepts | ninjasquad

The Contaminated Pills Puzzle also one of my favorite puzzle which is frequently asked in interviews.

## Puzzle

You have 5 jars of full 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?**

## Solution

- Mark the jars with numbers 1, 2, 3, 4, and 5.
- 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.
- Put all of them on the scale at once and take the measurement.
- Now, subtract the measurement from 150 ( 1
*10 + 2*10 + 3*10 + 4*10 + 5*10) - The result will give you the jar number which has contaminated pill.

Source: Internet