Skip to content

Instantly share code, notes, and snippets.

@tliff
Created July 10, 2010 14:13
Show Gist options
  • Save tliff/470731 to your computer and use it in GitHub Desktop.
Save tliff/470731 to your computer and use it in GitHub Desktop.
awin=0
bwin=0
1000000.times do |i|
puts i
str = ''
stop = false
while !stop
str += rand(2) == 1 ? 't' : 'h'
if /tht/ =~ str
stop = true
awin += 1
end
if /thh/ =~ str
stop = true
bwin += 1
end
end
end
puts "A won #{awin} times. B won #{bwin} times"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment