National Squishyball League Championship

Another week, another Riddler. The question:

You and three of your friends are on a game show. On stage is a sealed room, and in that room are four sealed, numbered boxes. Each box contains one of your names, and each name is in one box. You and your friends take turns entering the room alone and opening up to two boxes, with the aim of finding the box containing your name. Everyone enters exactly once. Your team can confer on a strategy before stepping on stage, but there is no communication allowed during the show — no player knows the outcome of another player’s trip into the room.

Your team wins if it’s ultimately revealed that everyone found the box containing his or her name and loses if any player failed to do so. Obviously, the odds of winning are no better than 50 percent because any single player has a 50 percent chance of finding his or her own name. If each person opens two boxes at random, the chance of winning is (1/2)4=1/16=6.25(1/2)4=1/16=6.25percent. Or to put it in technical terms: The chance of winning is not so great. Call this the naive strategy.

Your goal: Concoct a strategy that beats the naive strategy — one that gives the team a better chance of winning than 1/16.

Extra credit: Suppose there are 100 contestants and 100 boxes. Each player may open 50 boxes. The chance of winning by using the naive strategy is 1 in $2^{100} \$

, or about 1 in 1.2×10301.2×1030. How much can you improve the team’s chances?

To find this you have to find the expected value for each number of games. This ended up being:

$\sum_{n=0}^{f_{t}-1}\left(p^{f_{t}+n}\right)\left(\left(1-p\right)^{f_{t}-1-n}\right)\left(\frac{\left( 2f_{t}-1\right)!}{\left(f_{t}+n\right)!\left(f_{t}-1-n\right)!}\right)$

Where

$n =$ number of games won

$f_{t} =$ series is first to _

$p =$ probability Axegrinders win

What the heck is this? Oh man good question. Okay so first we assume that in each case we are playing the full number of games. So if it is a first to 3 (commonly referred to as a best of 5) then we are going to play five games, even if we win the first 3. This can lead to “extra” wins, but helps keep the math concise. So again in the first to 3 case:

 Axegrinders Wins Barbarians wins Ways this can occur First to 3 3 2 10 4 1 5 5 0 1

So the equation would take n=0 (no extra wins) to make the top row. The probability this happens is

$\left ( 0.6 \right )^{3}\left ( 0.4 \right )^{2}\cdot 1$

summed with the next two rows:

$\left ( 0.6 \right )^{4}\left ( 0.4 \right )\cdot 5$

$\left ( 0.6 \right )^{5}\cdot 10$

this sum, equal to 0.68, is the chance that the Axegrinders win the series. This is multiplied by the payout to get the expected value (662,000).

This gives us this wonky looking graph:

The result of this is the optimal payout is when the Axegrinders choose to play a first to 13, or best of 25. Doing so will give them an expected return of \$736,222.

The code:

import math
import matplotlib.pyplot as plt

#Chances of winning
def c_o_w(prob,first_to):
chance_of_winning = 0
for i in range(0,first_to):
games = 2*first_to-1
a_wins = first_to+i
b_wins = games-a_wins
individ_prob = prob**(a_wins)*(1-prob)**(b_wins)*math.factorial(games)/(math.factorial(a_wins)*math.factorial(b_wins))
chance_of_winning += individ_prob
return(chance_of_winning)

#Calculated chances of winning, payout and ev for each series length
chances = []
payout = []
ev = []
x = []
for series_length in range(1,86):
chances.append(c_o_w(0.6,series_length))
payout.append(100-series_length)
ev.append(chances[series_length-1]*payout[series_length-1])
x.append(series_length)

#Oh man I gotta graph this
fig, ax = plt.subplots(sharey=False)
pev, = ax.plot(x,ev, color = 'b', label = 'Expected Value')
ax.set_ylabel("Dollars, in Thousands", color = 'b')
ppay, = ax.plot(x,payout,color = 'g', label = 'Payout')
ax.tick_params('y',colors = 'b')
ax.set_xlabel("Best of _ Series")

ax2 = ax.twinx()
pchance, = ax2.plot(x,chances, color = 'm', label = 'Probability to win series')
ax2.set_ylabel("Chances Axegrinders Win Series", color = 'm')
ax2.tick_params('y',colors = 'm')
fig.tight_layout()
plt.title('Axegrinders Series Length Selection')
fig.legend([pev,ppay,pchance],['Expected Value', 'Payout', 'Chances Axegrinders Win Series'],loc='lower right', borderaxespad=8.)
plt.show()