File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programming Diversions and the fly likes measurment  puzzle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "measurment  puzzle" Watch "measurment  puzzle" New topic

measurment puzzle

rehans oberoi
Ranch Hand

Joined: Dec 06, 2005
Posts: 174
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?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Do all jars contain the same numbers of pills and how much?
We may select as many as we like?

The contaminated pills are red!
Murali Mohan
Ranch Hand

Joined: Jan 09, 2006
Posts: 66
let the weight of each uncontaminated pill be 'x'
so weight of contaminated pill is 'x+1'

there are 4 jars ( say 1, 2 ,3 and 4)

now take 1 pill from jar 1
now take 2 pills from jar 2
now take 3 pills from jar 3
now take 4 pills from jar 4

weigh them all together.
now the weight will be 10x + n
where n is the jar number which contains the contaminated pills.

let me know if I am wrong.

Thanks,<br />Murali...
I agree. Here's the link:
subject: measurment puzzle
It's not a secret anymore!