## Riddler Express

You’re driving a car down a two-mile track. For the first mile, you drive 30 miles per hour. How fast do you have to go for the second mile in order to average 60 miles per hour for the whole track?

## Solution

We have the following equation:

\[ \begin{equation*} 60 = \frac{2}{\frac{1}{30} + \frac{1}{s}} \end{equation*} \]

From the above it is obvious that achieving an average speed of 60 miles per hour is not possible.

## Riddler Classic

A town of \$1,000 households has a strange law intended to prevent wealth-hoarding. On January \(1\) of every year, each household robs one other household, selected at random, moving all of that house’s money into their own house. The order in which the robberies take place is also random and is determined by a lottery. (Note that if House \(A\) robs House \(B\) first, and then \(C\) robs \(A\), the houses of \(A\) and \(B\) would each be empty and \(C\) would have acquired the resources of both \(A\) and \(B\).)

Two questions about this fateful day:

What is the probability that a house is not robbed over the course of the day?

Suppose that every house has the same amount of cash to begin with — say \$100. Which position in the lottery has the most expected cash at the end of the day, and what is that amount?

## Solution

```
from random import sample
= 10000
runs = 1000
num_houses = [0] * num_houses
final_amts = 0
total_num_safe
= {i:(set(range(num_houses))-set([i]))
rob_choices for i in range(num_houses)}
= list(range(num_houses))
lottery = [None] * num_houses
rob = [None] * num_houses
amts for _ in range(runs):
for i in range(num_houses):
= 100
amts[i] = sample(rob_choices[i], 1)[0]
rob[i] += (num_houses - len(set(rob)))
total_num_safe
shuffle(lottery)for h in lottery:
+= amts[rob[h]]
amts[h] = 0
amts[rob[h]] for i,j in enumerate(lottery):
+= amts[j]
final_amts[i]
print(total_num_safe/(runs*num_houses))
= max(zip(final_amts, range(num_houses)))
amt, pos print(amt/runs, pos)
```

The percent of houses that are not robbed on average is \(37\). The position in the lottery with the most expected cash is the *last* position and the maximum expected cash amount is \$137.