David Robinson takes us through another problem-solving challenge:
You are locked in the dungeon of a faraway castle with three fellow prisoners (i.e., there are four prisoners in total), each in a separate cell with no means of communication. But it just so happens that all of you are logicians (of course)….
Each prisoner will be given a fair coin, which can either be fairly flipped one time or returned to the guards without being flipped. If all flipped coins come up heads, you will all be set free! But if any of the flipped coins comes up tails, or if no one chooses to flip a coin, you will all be doomed to spend the rest of your lives in the castle’s dungeon.
The only tools you and your fellow prisoners have to aid you are random number generators, which will give each prisoner a random number, uniformly and independently chosen between zero and one.
What are your chances of being released?
I’ll solve this with tidy simulation in R, in particular using one of my favorite functions, tidyr’s
crossing()
. In an appendix, I’ll show how to get a closed form solution for N = 4.I’ve also posted a 30-minute screencast of how I first approached the simulation and visualization.
Click through for the solution and explanation.
Comments closed