# Should You Pay \$250 To Play This Casino Game?

#### A FiveThirtyEight Riddler puzzle.

By Vamshi Jandhyala in Riddler mathematics

March 25, 2016

## Problem

Suppose a casino invents a new game that you must pay \$250 to play. The game works like this: The casino draws random numbers between 0 and 1, from a uniform distribution. It adds them together until their sum is greater than 1, at which time it stops drawing new numbers. You get a payout of \$100 each time a new number is drawn.

For example, suppose the casino draws 0.4 and then 0.7. Since the sum is greater than 1, it will stop after these two draws, and you receive $200. If instead it draws 0.2, 0.3, 0.3, and then 0.6, it will stop after the fourth draw and you will receive \$400. Given the \$250 entrance fee, should you play the game?

Specifically, what is the expected value of your winnings?

## Solution

```
from random import random
runs = 10000
def average_winnings(payout, runs = runs):
total = 0
for _ in range(runs):
total_draw = random()
total += payout
while(total_draw < 1):
total_draw += random()
total += payout
return total/runs
print("Average winnings: ", average_winnings(100))
```

The average winnings is $\approx \$272$.