Advertisement
Guest User

rps

a guest
Oct 6th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.70 KB | None | 0 0
  1. def winner(first, second)
  2.   if (first[1].downcase == "p" && second[1].downcase == "r") ||
  3.      (first[1].downcase == "r" && second[1].downcase == "s") ||
  4.      (first[1].downcase == "s" && second[1].downcase == "p")
  5.     return first
  6.   elsif (second[1].downcase == "p" && first[1].downcase == "r") ||
  7.         (second[1].downcase == "r" && first[1].downcase == "s") ||
  8.         (second[1].downcase == "s" && first[1].downcase == "p")
  9.     return second
  10.   elsif (first[1].downcase == "p" && second[1].downcase == "p") ||
  11.         (first[1].downcase == "r" && second[1].downcase == "r") ||
  12.         (first[1].downcase == "s" && second[1].downcase == "s")
  13.     return first
  14.   else
  15.     return false
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement