-
-
Save hoverbird/1087645 to your computer and use it in GitHub Desktop.
Arghhhh
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
# 4<w<8, 1<y<10, x and z are 6-sided dice. | |
HOW_MANY = 100000 | |
def range_rand(min,max) | |
min + rand(max-min) | |
end | |
def test_it | |
w = range_rand(4,8) | |
x = range_rand(1,6) | |
y = range_rand(1,10) | |
z = range_rand(1,6) | |
return ((w+x) > (y+z)) | |
end | |
results = [] | |
HOW_MANY.times do |test| | |
result = test_it | |
results << result | |
puts("test #{test}: "+result.to_s) | |
end | |
trues = results.select { |val| val == true } | |
falses = results.select { |val| val == false } | |
puts trues.size | |
puts falses.size | |
ratio = trues.size.to_f/results.size.to_f | |
puts ratio | |
puts "i am literally losing my mind" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment