Created
March 31, 2009 13:22
-
-
Save jimweirich/88188 to your computer and use it in GitHub Desktop.
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
fortune = 0 | |
max = 1000000 | |
for i in 1..max do | |
n = rand(100) + 1 | |
if (n <= 50) then fortune = fortune - 1 | |
elsif (n >= 51 && n <= 65) then fortune = fortune + 0 | |
elsif (n >= 66 && n <= 75) then fortune = fortune + 0.5 | |
elsif (n >= 76 && n <= 99) then fortune = fortune + 1 | |
elsif (n == 100) then fortune = fortune + 2 | |
else puts "#{i}: n:#{n}" | |
end | |
end | |
puts fortune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment