FiveThirtyEight Riddler

Will the Neurotic Basketball Player Make His Next Free Throw?

This week’s Riddler asks:

A basketball player is in the gym practicing free throws. He makes his first shot, then misses his second. This player tends to get inside his own head a little bit, so this isn’t good news. Specifically, the probability he hits any subsequent shot is equal to the overall percentage of shots that he’s made thus far. (His neuroses are very exacting.) His coach, who knows his psychological tendency and saw the first two shots, leaves the gym and doesn’t see the next 96 shots. The coach returns, and sees the player make shot No. 99. What is the probability, from the coach’s point of view, that he makes shot No. 100?


We will solve by brute force: simulation!

# r

shootFreethrows <- function(){
  shots <- c(1, 0)
  for(i in 3:100){
    p <- mean(shots)
    shot <- sample(x = c(1, 0), size = 1, prob = c(p, 1 - p))
    shots <- c(shots, shot)
  if(shots[99] == 1){

shootFreethrowsRepeatedly <- function(){
  results <- unlist(pbreplicate(10000000, shootFreethrows()))


After many, many (10,000,000) simulated games, we find that he makes his 100th freethrow 2/3rds of the time that he makes his 99th.

How Long Will Your Smartphone Distract You From Family Dinner?

This week’s Riddler asks:

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.)


When we simulate this situation, as I did 10,000,000 times, you get 9 minutes on average.

# python
import random

def waitForDinner():
    a = random.sample((1,2,3,4,5), 1)[0]
    b = random.sample((1,2,3,4,5), 1)[0]
    while(a != b):
        if(a > b):
            b += random.sample((1,2,3,4,5), 1)[0]
            a += random.sample((1,2,3,4,5), 1)[0]
    return a

def waitForDinnerRepeatedly():
    waits = []
    for i in range(10000000):
    return sum(waits) / len(waits)