Work A Shift In The Riddler Gift Shop

A FiveThirtyEight Riddler puzzle.

August 25, 2017

Riddler Express

You take half of a vitamin every morning. The vitamins are sold in a bottle of 100 (whole) tablets, so at first you have to cut the tablets in half. Every day you randomly pull one thing from the bottle — if it’s a whole tablet, you cut it in half and put the leftover half back in the bottle. If it’s a half-tablet, you take the vitamin. You just bought a fresh bottle. How many days, on average, will it be before you pull a half-tablet out of the bottle?

Extra credit: What if the halves are less likely to come up than the full tablets? They are smaller, after all.


from random import random

runs = 100000
init_full_tablets = 100
num_days_till_half_tablet = 0

for _ in range(runs):
    num_full_tablets = init_full_tablets
    num_half_tablets = 0
        prob_full_tablet = num_full_tablets/(num_full_tablets + num_half_tablets)
        prob_half_tablet = 1 - prob_full_tablet
        num_days_till_half_tablet += 1
        if random() <= prob_full_tablet:
            num_full_tablets -= 1
            num_half_tablets += 1
            num_half_tablets -= 1

On average, it will take \(13.2\) days to pull a half-tablet out of the bottle.

Back to top