Created
March 29, 2013 05:13
-
-
Save weirenw/5268884 to your computer and use it in GitHub Desktop.
You have 20 bottles of pills, 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 gram. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get 1 pill from bottle 1, 2 pills from bottle 2... 10 pills from botthle 10. | |
Measure the weight. | |
If the weight is 0.1 gram more than 55. The ans is bottle 1. | |
.................0.x gram more than 55. The ans is bottle x. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment