GitHunt
RU

RuthvikSaiKumar/100-Prisoners-Riddle

This is the program written to prove the 100 Prisoners Riddle made by Veritasium.

100-Prisoners-Riddle

This is the program written to prove the 100 Prisoners Riddle made by Veritasium.

First it calculates the probability of the prisoners winning on hundred attampts (to calculate the percentage),

then, I repeated it for 1000 times to calculate the average percentage of winning.

Output:

| ████████████████████████████████████████████████████████████████████████████████████████████████████  | 100 % done
Average number of times prisoners are freed: 30.026%

The value comes close to what was expected by Veritasium.

You can repeat the calculation any number of times to calculate precise average (by changing the times variable).

You can also change the number of prisoners.

Thank you for reading!
Have a good day 😄

Languages

Python100.0%

Contributors

MIT License
Created June 30, 2022
Updated October 14, 2025
RuthvikSaiKumar/100-Prisoners-Riddle | GitHunt