GitHunt
LU

lukass-code/100_prisoners_problem

A code to solve the 100 prisoners problem

100 Prisoners Problem

Description

"The 100 prisoners problem is a mathematical problem in probability theory and combinatorics. In this problem, 100 numbered prisoners must find their own numbers in one of 100 drawers in order to survive. The rules state that each prisoner may open only 50 drawers and cannot communicate with other prisoners. At first glance, the situation appears hopeless, but a clever strategy offers the prisoners a realistic chance of survival." (Source: Wikipedia)

For more information read the full article: 100 prisoners problem

This video describes it very well: Video

Code

I wanted to take a closer look at this problem and to retrace the solution approach. The solution is very interessting. This code is used to model the problem. In addition, the solution is implemented and the probability of success can be calculated.

Have fun trying it out yourself.

Requirements:

  • numpy (pip install numpy)

Languages

Python100.0%

Contributors

Created July 7, 2022
Updated July 12, 2022