This is a simulation of the 100 Prisoners Riddle (description in the Notes and Credits). The goal of this project is to share this riddle with the world and test its wonderful solution by testing them numerically. Use Runs Change Increment to change the amount you change the number of runs by, and use the change runs UP and DOWN buttons to change the number of runs you simulate when you press the green flag. Change Success Rate D.P.s to change how many decimal points it shows. VARIABLES Prisoners: The number of prisoners there are in the simulation. Click 'see inside', go to system and change the number for this variable in the first script to test different numbers of prisoners. Boxes per Prisoner: The number of boxes each prisoner is allowed to check. To change, do the same as the above variable. Successes: The number of successes in your simulation. Progress: How many simulations about of how many it will simulate has been simulated. Success Rate: The percentage of simulations where the prisoners have succeeded in escaping. Success Rate D.P.s: The number of decimal points it shows in the Success Rate. Global Variables: The worldwide values of the above variables named similarly. The goal of this is to test the current best solution to this riddle. It will not be affected in you are not a Scratcher (i.e. you are not logged in or are a New Scratcher) or you have changed the code in any way.
The 100 Prisoners Riddle: (a more in-depth description&solution: https://www.youtube.com/watch?v=iSNsgj1OCLA ) There are 100 prisoners in a prison, each numbered from 1 to 100. However the guard gives them a chance to escape. There are 100 boxes, each numbered from 1 to 100, and they each have a slip of paper in them, which are also numbered from 1 to 100, but are in random boxes. Every prisoner would come in 1 by 1 (order is meaningless) and open any 50 boxes, and them put them back exactly how they were before they came in the room with the boxes. If they found the box with their own numbered paper in it, they succeed. The prisoners will be set free only if ALL 100 of them manage to find their numbered paper. The prisoners are allowed to strategise before they begin, but they can have no forms of communication whatsoever once they begin. What is the best strategy that gives them the highest chance of succeeding and being set free? Initially, this riddle seems impossible, since if a prisoner opens 50 of 100 boxes, they have a 50% chance of finding their paper; that makes their chance of succeeding 1/2 to the power of 100, or approximately a 0.000000000000000000000000000078886091% chance to succeed. Even with a group meeting beforehand, it seems impossible to create a plausible strategy to help them marginally in this problem, since once they start, they cannot communicate with each other. However, there is a solution that increases the prisoners' chance of escaping to a whopping (approximately) 31%! Try it yourself before continuing... The solution is to open the box with your number on it first, and then go to the box with the number written on the paper of the box that you have just opened, until you get to your number. For an explanation on why this is, check our Veritasium video: https://www.youtube.com/watch?v=iSNsgj1OCLA However, some parts of this video may be unclear. The reason all loops come back to themself is because if a box in a loop led to another loop, the two loops would inevitably become one loop, since there can only be one paper with the number of any box and each box only contains one piece of paper. Thank you for contributing to this project!