# Box of tablets, whole or broken: solution required

This is a puzzle that I thought up whilst taking a course of meds. I currently haven’t solved it, and would be curious to know if anyone has a solution for it. Here goes:

Scenario: John has a box of 15 tablets. He needs to take half a tablet per day for 30 days. Each day he takes the box and removes a tablet randomly (i.e. the chance of him removing a whole tablet is equal to him removing a half tablet when the number of whole- and half-tablets are equal. E.g. if there were 5 whole and 1 half tablet in the box, then p(half) = 1/6). If the tablet he removes is a whole one, he breaks it in half, eats one half, and returns the other half back to the box. If he removes a half tablet, he just consumes it. This continues for 30 days.

Question: On which day (on average, assuming infinite re-runs of the process) is he first going to be equally/more likely to remove a half tablet than a whole one?

I already have given this some thought, but even counting the number of permutations is impossible for me extrapolation from a 1 to 2 to 3 to 4 tablet simplification of the 15 tablet scenario above.

Any ideas/solutions welcome. Preferably the solutions would be hidden in a spoiler box, as for the time being I’m still trying to work it out myself.

Many thanks!

• Welcome to Puzzling! (Take the Tour!) I'm glad you’re interested in contributing this question here but I fear it likely falls on the wrong side of our policy on math problems vs puzzles — see Are math-textbook-style problems on topic? for some discussion. It’s an interesting question to want an answer to, but probably not enough on-topic to be here. – Rubio Aug 12 '19 at 0:18
• @Rubio IMO this is on the fence, but I think it should be ok. It's definitely not a textbook question for sure, and I do find it quite an interesting problem. So, I personally have no problem with this question, but I'd like to know what everyone else thinks. – greenturtle3141 Aug 12 '19 at 2:12
• @greenturtle3141 The solution path is mechanical, the answer is pretty much what I'd expect, and there's no particular magic about the answer—those are pretty much the hallmarks of "problem". Having said that, I (like you) am on the fence enough that I feel I need to leave it up to the community to decide. :) – Rubio Aug 12 '19 at 3:39
• As a person who submitted an answer, I have to agree that this didn't feel like a puzzle. I had fun finding an answer, but it was more of a coding problem than a puzzle. I think there might be a more elegant solution that involves thinking about the problem in forward time and backward time, but even then it would probably be a math problem. – hdsdv Aug 12 '19 at 9:24
• "removes a tablet perfectly randomly": Are we to assume that it's as likely that he'll pick a half as a whole, or that it's half as likely (because there's only one end to grasp but two ends of the whole tablet making the latter easier to choose)? Or should we work that out for ourselves as part of the solution? – msh210 Aug 12 '19 at 9:48

It turns out that on the 14th (edited from 13th - I was using zero index before) day, you are more likely to pick a half pill than a whole pill. On that day, the expected number of whole pills is ~5.597 and the expected number of half pills is ~5.807.

To do this,

I just wrote a Python program that enumerates all the possible outcomes each day, along with the probability that each outcome would occur. To compute tomorrow's possible outcomes, you take each possible situation S from today and check each "branch" that can happen - selecting a whole or half pill. Each branch has a probability of occurring (based on how many of each are in S), and a resulting situation (one less half pill, or one less whole pill and one more half pill). You multiply the probability of being in S by the probability of taking the branch, and add that to tomorrow's probability for S', the new situation that we just created.

Finally,

For each day, you can compute the expected number of whole pills (just multiply the number of whole pills in each situation by the probability of the situation). The total expected whole pills for the day will be the sum of all of these values. The same can be done for the half pills (and if you want to check your work, 2*expected_whole + expected_half should equal (30 - day), since that's how many total half-pills you still have left).

I can give you the Python code if you want. Not sure it can be spoilered (I've never learned how to have multi-line spoilers).

Python Code

• Rather than post code here, you should probably post it at (say) tio.run and link to it here - that way people can run it without having to download it and/or a python interpreter. – Rubio Aug 12 '19 at 0:06
• Thanks for the suggestion! Done. – hdsdv Aug 12 '19 at 0:26
• Re "Each branch has a probability of occurring": You may want to see my comment on the question. – msh210 Aug 12 '19 at 9:49
• I think if John were half as likely to choose a half pill than a whole pill, that would have been specified. It seems like a pretty important detail to leave out when everything else was specified unambiguously. This wasn't presented as a "find the small detail that I intentionally left out" puzzle. – hdsdv Aug 12 '19 at 10:15
• @MSH210 et al. Thank you for your responses. I’m a newbie here, I’m sorry if this doesn’t comply to your definition of a puzzle. Thanks for your responses in any case. Regarding “remove a tablet perfectly randomly”: Perhaps I should have expressed it differently. I imagined that John tips a (half) tablet out of the box, and the chance that it is a whole one reflects the proportion of whole tablets in the box (so for example if there are 6 whole and 2 half tablets in the box, p(whole)=0.75, p(half)=0.25. I hope that makes ig clear. – David Aug 12 '19 at 20:47

Starting at $$(0,0)$$, we do the followings:

• If a whole pill is taken, we move one unit to the right.
• If a half pill is taken, we move one unit upwards.

Therefore, if we are at point $$(x,y)$$ we have:

• $$(15-x)$$ whole pills left
• $$(x-y)$$ half pills left
• $$(15-y)$$ total pills left

Now we define $$f(x,y)$$ as the probability that we reach point $$(x,y)$$. Obviously,

$$f(0,0)=1$$ and $$f(-1,y)=0$$

We reach point $$(x,y)$$:

• From $$(x-1,y)$$ if we take a whole pill
• From $$(x,y-1)$$ if we take a half pill

Therefore,

$$f(x,y)=\frac{15-(x-1)}{15-y}f(x-1,y)+\frac{x-(y-1)}{15-(y-1)}f(x,y-1)$$

I use microsoft excel to calculate $$f(x,y)$$ for $$0\leq x \leq 15$$ and $$0\leq y \leq 15$$

Now, the expected value of # of half pills - # of whole pills after $$k$$ days is calculate by summing

$$((x-y)-(15-x))f(x,y)$$

for all $$(x,y)$$ which satisfy

$$x+y=k-1$$

This expected value becomes positive (we have more half pills than whole pills) for $$k\geq 14$$.