...or use your e-mail

Go back to Challenges list


Rock-Paper-Scissor Tournament

In this challenge you will be the judge in a Rock-Paper-Scissor (RPS) tournament. The rules of RPS are simple: Rock (R) beats Scissor (S), Scissor (S) beats Paper (P) and Paper (P) beats Rock (R).

You will receive a key/value array with the name of the player and his move (R, P or S) and each player always play that same move in all matches he/she plays.

The rules for this tournament are:
- The pairing for the matches must be done following the order of the players in the array
- The player's moves need to be validated before the tournment starts and if their move is not R, P or S they should be removed from the competition (do this before doing the pairing for the matches)
- The minimum number of players in the tournament must be 2
- If the number of player in the tournament is odd, the player without opponent advances to the next fase (yes, it will be unfair to the other players but that's life).
- If the players tie in a match, the first player (by the order in the array) is the winner

Input Format
Each input will be a string with the names of the players and their moves in the following format: "Paul-P,Dave-S,Jane-R,Mike-P"

Output Format
The output should be the name of the winner (Ex: "Dave") or "No tournament" if the number of players is not enough.

Sample Input

Sample Output

Memory Limit

Sign Up or Login to solve this Code Challenge