# A FiveThirtyEight Spelling Bee

Another week, another riddler. This weeks:

From Steven Pratt, ordinal bee probability:

You are competing in a spelling bee alongside nine other contestants. You can each spell words perfectly from a certain portion of the dictionary but will misspell any word not in that portion of the book. Specifically, you have 99 percent of the dictionary down cold, and your opponents have 98 percent, 97 percent, 96 percent, and so on down to 90 percent memorized. The bee’s rules are simple: The contestants take turns spelling in some fixed order, which then restarts with the first surviving speller at the end of a round. Miss a word and you’re out, and the last speller standing wins. The bee words are chosen randomly from the dictionary.

First, say the contestants go in decreasing order of their knowledge, so that you go first. What are your chances of winning the spelling bee? Second, say the contestants go in increasing order of knowledge, so that you go last. What are your chances of winning now?

Unfortunately I had to just brute for this one. Due to the nature of the problem I couldn’t think of a good way to put this into any sort of an equation. Here are the results:

import random
import matplotlib.pyplot as plt
import matplotlib.patches as patches

def play_round(player):
return random.randint(0,99) > player

def play_game():
players = [1 for i in range(1,11)]
players_left = sum(players)

player_up = 0
while players_left > 1:
if players[player_up]:
if not play_round(player_up):
players[player_up] = 0
player_up = (player_up + 1) % len(players)
players_left = sum(players)
return players.index(1)

#Run cycles

winners = [0 for i in range(1,11)]
for cycles in range(100000):
winner = play_game()
winners[winner] += 1
if (cycles%10000 == 0): print(winners)

## Configure for plotting

percents = [float(winners[i])/cycles for i in range(len(winners))]
players_for_plotting = [99-i for i in range(10)]

fig = plt.figure()