First, let's think about what we actually did. The problem tells us that we're drawing random numbers from the interval [0,1] until their sum exceeds 1. This is basically the same as asking us to keep rolling an -sided die, with sides numbered from 1 to , until their sum exceeds itself. I showed the steps we'd use to solve for = 5, generalized for any , and then showed that as goes to infinity, this sum approaches the mathematical constant e.
This week's puzzle specifically requested that we solve it by hand, which I did:
— Mike Vanderheyden (@_mikebot) March 25, 2016
But I couldn't resist running a simulation to check my work. So here's a bit of Python where I did so, running 100,000 trials of the dice-rolling variant of the casino game for every value of from 1 to 99:
And here's the result:
For a 1-sided die, you would obviously always need exactly 2 rolls to exceed a sum of 1 so the expected (gross) winnings are $200. For a 2-sided die, 1/4 of the time you'd roll two consecutive 1s and have to roll a third time; otherwise you'll be done in exactly 2 rolls, so the expected winnings are $225. As you can see, the expected number of rolls quickly approaches the analytical solution of $100e $271.83 we came up with.