Skip to content

Instantly share code, notes, and snippets.

@perspectivezoom
Created June 18, 2012 22:28
Show Gist options
  • Save perspectivezoom/2951137 to your computer and use it in GitHub Desktop.
Save perspectivezoom/2951137 to your computer and use it in GitHub Desktop.
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