3 ms·
Flipping 76 in a row is extremely improbable in the physical world, but fortunately we have computers (Where it's still quite improbable). [10] pry(main)>
by Aaronneyer 13y ago
Flipping 76 in a row is extremely improbable in the physical world, but fortunately we have computers (Where it's still quite improbable).
[10] pry(main)> choices, tries, current, current_max = [:heads, :tails], 0, 0, 0
[10] pry(main)> loop do
[10] pry(main)* tries += 1
[10] pry(main)* flip = choices.sample
[10] pry(main)* if flip == :heads
[10] pry(main)* current += 1
[10] pry(main)* else
[10] pry(main)* current = 0
[10] pry(main)* end
[10] pry(main)* if current > current_max
[10] pry(main)* current_max = current
[10] pry(main)* puts "New max: #{current_max}, after #{tries} tries"
[10] pry(main)* end
[10] pry(main)* end
Highest so far: "New max: 31, after 77576302 tries"