This week’s Riddler was about probability and maximizing probability of surviving a punishment. The official text is:

### The Problem:

*While traveling in the Kingdom of Arbitraria, you are accused of a heinous crime. Arbitraria decides who’s guilty or innocent not through a court system, but a board game. It’s played on a simple board: a track with sequential spaces numbered from 0 to 1,000. The zero space is marked “start,” and your token is placed on it. You are handed a fair six-sided die and three coins. You are allowed to place the coins on three different (nonzero) spaces. Once placed, the coins may not be moved.*

*After placing the three coins, you roll the die and move your token forward the appropriate number of spaces. If, after moving the token, it lands on a space with a coin on it, you are freed. If not, you roll again and continue moving forward. If your token passes all three coins without landing on one, you are executed. On which three spaces should you place the coins to maximize your chances of survival?*

### The Process:

To solve this you should use a few thoughts:

- The chance to land on a square is the average of the previous six squares
- The chance to land on anything below 0 is 0. The chance to “land” on zero is 1
- You only need to escape once — once you land on a square with a coin on it the game is over

Using these my code framework is pretty simple. In psuedocode:

for square_selection in range(0,3): set values representing square(-5) to square(-1) to 0 set values representing square(0) to 1 for squares(1) to square(1000): chance to land on it = average of previous six squares if the square was a "highscore" before: set its chance to 0 highscore = index of max(square(1) to square(1000)) plot it

### The Results:

Here is the results of probability of landing on each square if no coin has been placed

This makes the first coin placement, on square 6, very easy. Then the values of the following squares actually decrease because the possibility of getting to them from a six are removed. This leads to the following:

where the red represents the first placement, the blue the second and the green the second.

As a result the squares you should place coins on are 4, 5, and 6. Doing so will net you a 79% chance of survival — pretty good!