Riddler Express
I have three dogs: Fatch, Fetch and Fitch. Yesterday, I found a brown -inch stick for them to play with. I marked the top and bottom of the stick and then threw it for Fatch. Fatch, a Dalmatian, bit it in a random spot — leaving a mark — and returned it to me. In her honor, I painted the stick black from the top to the bite and white from the bottom to the bite.
I subsequently threw the stick for Fetch and then for Fitch, each of whom retrieved the stick by biting a random spot. What is the probability that Fetch and Fitch both bit the same color (i.e., both black or both white)?
Solution
The three bite marks can be permuted in ways all of which are equally likely because of symmetry. Out of the permutations, there are permutations where the bite marks of Fitch and Fetch lie on one side of the bite mark of Fatch. Therefore, the probability that Fetch and Fitch both bit the same color is .
From the simulation below, we see that the probability that Fetch and Fitch both bit the same color is indeed .
from random import random
def prob(runs = 1000000):
succ_cnt = 0
for _ in range(runs):
fa, fe, fi = random(), random(), random()
if (fe < fa and fi < fa) or (fe > fa and fi > fa):
succ_cnt += 1
return succ_cnt/runs
print(prob())
Riddler Classic
Italy defeated England in a heartbreaking (for England) European Championship that came down to a penalty shootout. In a shootout, teams alternate taking shots over the course of five rounds. If, at any point, a team is guaranteed to have outscored its opponent after five rounds, the shootout ends prematurely, even if each side has not yet taken five shots. If teams are tied after five rounds, they continue one round at a time until one team scores and another misses.
If each player has a percent chance of making any given penalty shot, then how many total shots will be taken on average?
Computational Solution
From the simulation below, we see that the total shots taken on average is .
def avg_total_shots(p, runs = 1000000):
from random import random
shot = lambda p: 1 if random() < p else 0
def game_over(t1, t2, g1, g2):
return 1 if max(5-t1, 0) + g1 < g2 or max(5-t2, t1-t2) + g2 < g1 else 0
sum_ts = 0
for _ in range(runs):
t1, t2, g1, g2 = 0, 0, 0, 0
while True:
t1, g1 = t1 + 1, g1 + shot(p)
if game_over(t1, t2, g1, g2):
break
t2, g2 = t2 + 1, g2 + shot(p)
if game_over(t1, t2, g1, g2):
break
sum_ts += t1+t2
return sum_ts/runs
print(avg_total_shots(0.7))