Created
June 18, 2012 22:28
-
-
Save perspectivezoom/2951137 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 game(ar) | |
throw1 = ar[0][1].downcase | |
throw2 = ar[1][1].downcase | |
if %w{ rs pr sp }.include?(throw1 + throw2) | |
return ar[0] | |
elsif %w{ sr rp ps}.include?(throw1 + throw2) | |
return ar[1] | |
else | |
"It's a Tie!" | |
end | |
end | |
def find_winner(ar) | |
if ar[0][0].is_a?(String) | |
if ar[1][0].is_a?(String) | |
game ar | |
else | |
find_winner([ar[0]] + [find_winner(ar[1])]) | |
end | |
else | |
find_winner([find_winner(ar[0])] + [ar[1]]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment