-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-1.txt
More file actions
14 lines (12 loc) · 872 Bytes
/
6-1.txt
File metadata and controls
14 lines (12 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# If you have 20 pill bottles where 19 bottle had 1 gram pills and 1 bottle with 1.1 gram pills
# How could you use a scale once to determine the pill bottle containing 1.1 gram pills?
If you had 2 pill bottles where 1 is 1 gram and the other 1.1 gram, and took 2 pills from one and 1 from the other,
you could weigh them determine which bottle has the heavier pills by whether the weight was off by 0.1 or 0.2.
Likewise, if you added a unique number of pills from each bottle, you could determine the bottle with the heavier pills.
This can be solved by an equation. Where the perfect weight with no heavy pills is the sum from 1 to N is (N + 1) / 2,
you find pill bottle by:
(weight - (N * (N + 1)) / 2) / 0.1
Example
2 pill bottles perfect weight is (2 * (2 + 1)) / 2 = 3
Scale reports weight of 3.2, then (3.2 - 3) / 0.1 = 2
So, pill bottle 2 has the heavier pills.