Guest User

Untitled

a guest
Dec 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.79 KB | None | 0 0
  1. class WrongNumberOfPlayersError < StandardError ; end
  2. class NoSuchStrategyError < StandardError ; end
  3.  
  4. def rps_result (m1, m2)
  5.   if m1 == "R"
  6.     if m2 == "R" 0
  7.     elsif m2 == "P" 1
  8.     elsif m2 == "S" 0
  9.     else
  10.       raise NoSuchStrategyError
  11.     end  
  12. #  elsif m1 == "P"
  13. #    if m2 == "R" 0
  14. #    elsif m2 == "P" 0
  15. #    elsif m2 == "S" 1
  16. #    else raise NoSuchStrategyError
  17. #    end  
  18. #  elsif m1 == "S"
  19. #    if m2 == "R" 1
  20. #    elsif m2 == "P" 0
  21. #    elsif m2 == "S" 0
  22. #    else raise NoSuchStrategyError
  23. #    end  
  24. #  else
  25. #    raise NoSuchStrategyError
  26.   end
  27. end
  28.  
  29. def rps_game_winner(game)
  30.     raise WrongNumberOfPlayersError unless game.length == 2
  31.     game[rps_result(game[0][1],game[1][1])]
  32. end
  33.  
  34. def rps_tournament_winner(tournament)
  35.    # YOUR CODE HERE
  36. end
Add Comment
Please, Sign In to add comment