Created
May 21, 2014 03:05
-
-
Save jackieiscool/2033f5eb4c012879f296 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
def roulette(bet, total) | |
unless total < bet | |
total -= bet | |
color = choose_color | |
if color == "black" | |
return bet * 2 + total | |
else | |
return roulette(bet * 2, total) | |
end | |
end | |
return total | |
end | |
def choose_color | |
wheel = (0..36).to_a << 0 | |
spin = wheel.sample | |
spin.odd? ? "black" : "red" | |
end | |
puts roulette(5, 300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment