Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Odd Pill 2

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
An interesting question brought to my attention last night. Its supposedly a MS interview question. Some people get it right away.

You have 5 bottles of pills. Each bottle contains 100 pills. In 4 bottles the pills weigh 10g each. In 1 bottle the pills weigh 9g each. All pills look identical. Using only 1 measurement how do you find which bottle contains the 9mg pills?

hint:
Code:
[white] The scale is not a difference scale.[/white]
 
Submerge the bottles under water and see which one floats higher than the others.

/random stab in the dark/

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
Code:
[white]take 1 pill from bottle 1
2 pills from bottle 2
3 from bottle 3
4 from bottle 4
5 from bottle 5

put these 15 pills together on the scale

subtract weight on the scale in g from 150g
diff in g points to bottle containing 9g pills[/white]

p5
 
My first solution was to read the bottles.

The only measurement solution I can think of would potentially require 2 measurements. Put two bottles on each side of the difference scale. If it balances then the odd bottle was the light one. Otherwise, take the lighter of the two sides and weigh the two bottles against each other.

The real solution is pretty cool though.
 
take 1 pill from bottle 1, 2 pills from bottle 2, 3 pilles from bottle 3, 4 pills from bottle 4, and 5 pills from bottle 5. Weigh the 15 pills. subtract their weight from 150. The resulting number is the number of the bottle you are looking for.
 
I think you can go up to as many bottles as there are pills, so with 100 pills in each of 100 bottles you can still identify the 9g pills with only one measurement.

[COLOR=black #d0d0d0]My alarm clock causes time travel. When I hit snooze, no apparent time passes before the alarm sounds again, but the universe has in fact moved forward through time by ten minutes![/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top