Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WrongNumberOfPlayersError < StandardError ; end
- class NoSuchStrategyError < StandardError ; end
- def rps_result (m1, m2)
- if m1 == "R"
- if m2 == "R" 0
- elsif m2 == "P" 1
- elsif m2 == "S" 0
- else
- raise NoSuchStrategyError
- end
- # elsif m1 == "P"
- # if m2 == "R" 0
- # elsif m2 == "P" 0
- # elsif m2 == "S" 1
- # else raise NoSuchStrategyError
- # end
- # elsif m1 == "S"
- # if m2 == "R" 1
- # elsif m2 == "P" 0
- # elsif m2 == "S" 0
- # else raise NoSuchStrategyError
- # end
- # else
- # raise NoSuchStrategyError
- end
- end
- def rps_game_winner(game)
- raise WrongNumberOfPlayersError unless game.length == 2
- game[rps_result(game[0][1],game[1][1])]
- end
- def rps_tournament_winner(tournament)
- # YOUR CODE HERE
- end
Add Comment
Please, Sign In to add comment