Skip to content

Instantly share code, notes, and snippets.

@threeifbywhiskey
Created August 18, 2014 03:37
Show Gist options
  • Save threeifbywhiskey/f45c88fd084e8b8cd86e to your computer and use it in GitHub Desktop.
Save threeifbywhiskey/f45c88fd084e8b8cd86e to your computer and use it in GitHub Desktop.
Monty Hall Problem simulation
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