4 ms·
I coded a simulation here if that helps: https://gist.github.com/bjornedstrom/971574557b6f3179db083508c8cf8c3b https://gist.github.com/bjornedstrom/971574557b6f
by bjornedstrom 10y ago
I coded a simulation here if that helps: https://gist.github.com/bjornedstrom/971574557b6f3179db083508c8cf8c3b https://gist.github.com/bjornedstrom/971574557b6f3179db08350...
- adium 10y agoThe first two times I ran it I got 0.298 and 0.286. Out of 20 attempts 5 were below 30%.
- hundt 10y ago1000 is a pretty small number of trials. Also note the docs on random.shuffle: Note that for even rather small len(x), the total number of permutations of x is larger than the period of most random number generators; this implies that most permutations of a long sequence can never be generated.[1] I don't know if we have any reason to believe that the small subset of all permutations that this library can generate is unbiased in terms of the size of the cycles. https://docs.python.org/2/library/random.html#random.shuffle https://docs.python.org/2/library/random.html#random.shuffle
- Guillaume86 10y agoI also coded a simulation, mine is in js: https://jsfiddle.net/a3ch3s5h/ https://jsfiddle.net/a3ch3s5h/ I only run once, you'll have to run it a few times to get a positive result. The output is displayed in the js console (F12 on most browsers). Edit: Something interesting I derived from the solution is that by allowing the first prisoner to reset the experiment if he fails or don't like the result, they get a 100% success rate. The first prisoner just need to wait for an arrangement which place him in a 50 length cycle (which means no other cycle can be of length > 50).