Skip to content

Instantly share code, notes, and snippets.

@jessieay
Created June 19, 2012 00:23
Show Gist options
  • Save jessieay/2951617 to your computer and use it in GitHub Desktop.
Save jessieay/2951617 to your computer and use it in GitHub Desktop.
Tournament of RPS contest
def game(match)
if match[0][1].upcase =="R"
if match[1][1].upcase == "P"
match[1]
elsif match[1][1].upcase == "S"
match[0]
else
"It's a Tie!"
end
elsif match[0][1].upcase =="P"
if match[1][1].upcase == "S"
match[1]
elsif match[1][1].upcase == "R"
match[0]
else
"It's a Tie!"
end
elsif match[0][1].upcase =="S"
if match[1][1].upcase == "R"
match[1]
elsif match[1][1].upcase == "P"
match[0]
else
"It's a Tie!"
end
end
end
def find_winner(tourney)
if tourney[0][0].class == String
game(tourney)
else
# a = find_winner(tourney[0])
# b = find_winner(tourney[-1])
# game([a,b])
game([find_winner(tourney[0]), find_winner(tourney[-1])])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment