All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Optimizing Potency (Posted on 2015-11-19) Difficulty: 4 of 5
My pills, which I buy 31 at a time, come in an airtight canister. Last month (December), I opened the canister 31 times, removing (and swallowing) one pill every day. The problem is that the last pill I took on December 31 was exposed to the air 31 times, which diminishes its potency. The December 1 pill was only exposed to air once. On average, the pills that I took were exposed to the air 16 times, calculated as (1 + 31)/2.

But I can do better in January, because now I have an empty canister!

On January 1, I could swallow one pill and transfer 15 to the empty canister. If I make no more transfers, the remaining 30 pills will be exposed an additional 8 times on average, i.e (15+1)/2, in addition to the once that they have already been exposed. Average time exposed for all 31 pills is (1 + 30*(8+1))/31 = 271/31 = 8.742. A significant improvement from 16! I feel healthier already!

I think that I can do better if I transfer pills between my two canisters more frequently. What is the best I can do? How?

See The Solution Submitted by Steve Herman    
Rating: 5.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Possible approach. | Comment 1 of 10

Let's start with the given examples, and arrange some notation.

1. Each time I open a canister, I mark every pill in it with a small m before I eat any. So, in example 1, I will mark all 31 pills on the first day, 30 on the second day..., and the last pill will be plastered with 31 m's. Total 496m.
2. In example 2, I mark every pill with a m, eat 1, and put 15 in container 2. This container is C, for Current, the other is R, for Reserve. I always eat the pills in C first. The next day I mark every pill in C and so on, for a total of 135m, plus one for the first day, 136m in all.
3. Now before I eat any pills in R I must mark them all again. There will be 3m on the first pill I eat, 4m on the second, etc, for a total of 150m. 136+150 = 286m, an improvement on the first example.
4. Since 4*8=32, I could transfer 8 pills to C three times, then eat the 6 left in R, for a score of 44+1+52+60+45 = 202m, still gaining ground.
5. Since 5*6=30,  I could transfer 6 pills to C four times, then eat the 6 left in R: 27+1+33+39+45+51 = 196m.
6. But also 6*5=30: 20+1+25+30+35+40+45, for a score of 196m.

Is it possible to improve on 196? The answer seems to be no. Call the number of pills transferred each time, t. Let T(n) signify the nth triangular number. The number of transfers is then (30/t)-1, The number of marks is 1+T(t+1)-1+T(t+2)-3+T(t+3)-6+T(t+4)-10, etc. By interpolating those fractions (30/4, 30/7, 30/8, 30/9) where there is no integer divisor of 30, we can obtain the closed form a(n) = (15n^2+31n+450)/n for the total number of marks, giving these values:

30 496
29 481.5172414
28 467.0714286
27 452.6666667
26 438.3076923
25 424
24 409.75
23 395.5652174
22 381.4545455
21 367.4285714
20 353.5
19 339.6842105
18 326
17 312.4705882
16 299.125
15 286
14 273.1428571
13 260.6153846
12 248.5
11 236.9090909
10 226
9 216
8 207.25
7 200.2857143
6 196
5.9 195.7711864
5.8 195.5862069
5.7 195.4473684
5.6 195.3571429
5.59 195.3508945
5.58 195.3451613
5.57 195.3399461
5.56 195.3352518
5.55 195.3310811
5.54 195.3274368
5.53 195.3243219
5.52 195.3217391
5.51 195.3196915
5.5 195.3181818
5.49 195.3172131
5.48 195.3167883
5.47 195.3169104
5.46 195.3175824
5.45 195.3188073
5.44 195.3205882
5.43 195.3229282
5.42 195.3258303
5.41 195.3292976
5.4 195.3333333
5.3 195.4056604
5.2 195.5384615
5.1 195.7352941
5 196
4 203.5
3 226
2 286
1 496

So 196 cannot be beaten.


Edited on November 20, 2015, 3:21 am
  Posted by broll on 2015-11-20 03:06:03

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information