Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 5

How Long Will Your Smartphone Distract You From Family Dinner?

You’ve just finished unwrapping your holiday presents. You and your sister got brand-new smartphones, opening them at the same moment. You immediately both start doing important tasks on the Internet, and each task you do takes one to five minutes. (All tasks take exactly one, two, three, four or five minutes, with an equal probability of each). After each task, you have a brief moment of clarity. During these, you remember that you and your sister are supposed to join the rest of the family for dinner and that you promised each other you’d arrive together. You ask if your sister is ready to eat, but if she is still in the middle of a task, she asks for time to finish it. In that case, you now have time to kill, so you start a new task (again, it will take one, two, three, four or five minutes, exactly, with an equal probability of each). If she asks you if it’s time for dinner while you’re still busy, you ask for time to finish up and she starts a new task and so on. From the moment you first open your gifts, how long on average does it take for both of you to be between tasks at the same time so you can finally eat? (You can assume the “moments of clarity” are so brief as to take no measurable time at all.)

The Riddler, FiveThirtyEight(original post)

Solution

Model each sibling as a stream of tasks whose lengths are independent and uniform on {1,2,3,4,5}\{1,2,3,4,5\} minutes, so a task lasts μ=(1+2+3+4+5)/5=3\mu = (1+2+3+4+5)/5 = 3 minutes on average. A sibling is “between tasks” exactly at the running totals of their task lengths; call these the sibling’s break points. Dinner happens at the first minute that is a break point for both. We want the expected value of that minute.

Look at the integer minute marks t=1,2,3,t=1,2,3,\dots and track each sibling by a residual: the number of minutes left on their current task. Both residuals fall by one each minute. When a residual reaches zero that sibling is at a break point and immediately starts a fresh task, drawing a new residual uniform on {1,,5}\{1,\dots,5\}. A shared break point is a minute at which both residuals reach zero together.

Here is the key observation. At time 00 both siblings open their phones and draw a first task, so the pair of residuals is two independent uniform{1,,5}\{1,\dots,5\} draws. That is exactly the state of the pair immediately after any shared break point, when both have just started fresh tasks. The process therefore regenerates at every shared break: the stretch from one shared break to the next is a fresh, independent copy of the stretch from time 00 to the first shared break. In particular, the wait we want has the same distribution as a typical gap between consecutive shared breaks.

Now count. The task lengths have greatest common divisor 11, so for large tt the chance that a given minute is a break point of one sibling settles down to 1/μ1/\mu: one break per task, one task per μ\mu minutes. The two siblings are independent, so the chance a given large minute is a break point for both is 1/μ×1/μ=1/μ21/\mu \times 1/\mu = 1/\mu^2. Shared breaks therefore occur at long-run rate 1/μ21/\mu^2, and a regenerative stream with rate 1/μ21/\mu^2 has mean gap equal to the reciprocal, μ2\mu^2. Since the first shared break after time 00 is one such gap, E[wait]=μ2=32=9 minutes.\mathbb{E}[\text{wait}] = \mu^2 = 3^2 = \boxed{9 \text{ minutes}}.

The computation

Encode the residual process directly. The state (a,b)(a,b) records the minutes left on each sibling’s current task, with a,b{1,,5}a,b\in\{1,\dots,5\}. One minute passes; whichever residual was 11 hits zero and is redrawn uniformly, and if both were 11 a shared break has occurred. Writing g(a,b)g(a,b) for the expected further wait from state (a,b)(a,b) gives a linear system, solved exactly in rationals; averaging gg over the 2525 equally likely starting states returns the answer.

import sympy as sp
S = [(a, b) for a in range(1, 6) for b in range(1, 6)]   # minutes left
idx = {s: i for i, s in enumerate(S)}
M = sp.zeros(len(S), len(S)); c = sp.zeros(len(S), 1)
fifth = sp.Rational(1, 5)
for (a, b) in S:
    i = idx[(a, b)]; M[i, i] += 1; c[i] = 1     # one minute passes
    if a == 1 and b == 1:
        continue                                # both finish: shared break
    elif a == 1:                                # only A finishes, redraw it
        for ap in range(1, 6): M[i, idx[(ap, b - 1)]] -= fifth
    elif b == 1:                                # only B finishes, redraw it
        for bp in range(1, 6): M[i, idx[(a - 1, bp)]] -= fifth
    else:                                       # neither finishes
        M[i, idx[(a - 1, b - 1)]] -= 1
g = M.solve(c)                                  # expected wait per state
print(sum(g[idx[s]] for s in S) / 25)           # 9