Created
August 18, 2014 03:37
-
-
Save threeifbywhiskey/f45c88fd084e8b8cd86e to your computer and use it in GitHub Desktop.
Monty Hall Problem simulation
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
def monty_hall | |
doors = ['goat', 'stupid goat', 'car'] | |
doors.delete choice = doors.sample | |
doors.delete reveal = doors.grep(/goat/).sample | |
puts 'Stay or switch?' until %w[stay switch].include? action = gets.chomp | |
choice = doors.last if action == 'switch' | |
puts "You got a #{choice}!" | |
end | |
loop { monty_hall } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment