Created
May 20, 2014 04:33
-
-
Save ucarion/dd6d390956a4fa118279 to your computer and use it in GitHub Desktop.
Random-sorting 8-groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people = (0...8).to_a | |
tries = 10_000_000 | |
count = 0 | |
tries.times do | |
if people.shuffle.each_with_index.all? { |person, index| person != index } | |
count += 1 | |
end | |
end | |
p count.to_f / tries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment