Skip to content

Instantly share code, notes, and snippets.

@brendon
Last active August 26, 2021 22:21
Show Gist options
  • Save brendon/5511580e020c7e489beee43447d4b64e to your computer and use it in GitHub Desktop.
Save brendon/5511580e020c7e489beee43447d4b64e to your computer and use it in GitHub Desktop.
Is Geoff Right? He is
# To run this just install Ruby (it's already on Macs), download this file
# into a folder, open your terminal and `cd` into that folder type:
# `ruby is_geoff_right.rb`
cars = 0
goats = 0
1000000.times do
doors = [:car, :goat, :goat]
first_choice = doors.delete_at(rand(3))
remaining_doors = if doors[0] == :goat
[first_choice, doors[1]]
else
[first_choice, doors[0]]
end
our_choice = remaining_doors[1]
if our_choice == :car
cars += 1
else
goats += 1
end
end
puts "Cars: #{cars} Goats: #{goats}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment