Problem Statement | |||||||||||||
A very exciting Paper-Rock-Scissors tournament has just begun! In qualifications, each player must face all his opponents in head to head games consisting of 5 throws. On each throw, each player will choose one of the following: Paper ('P'), Rock ('R') or Scissors ('S'). The winner of a throw is determined as follows: Paper always wins against Rock Rock always wins against Scissors Scissors always win against Paper In case both players make the same choice, it's a tie and no one wins. The winner of a game is the player who wins more throws. If both players win the same number of throws, the game ends in a tie (since these are qualifications, ties are allowed). To determine who passed the qualifications, a scoring system is implemented as follows: For every game won, the player is awarded one point. For every game tied, the player is awarded half of a point. For every game lost, the player is awarded zero points. Only a single player will pass the qualifications, namely the player with the most points. If several players have the same amount of points, the player which comes first in the input wins. All players observe a simple strategy: each of them prepares a sequence of throws and plays the same sequence in every game. Write a program that will receive a String[] players representing the sequence of throws for all players and returns the 0-based index of the player who will pass the qualifications. Each element of players will contain exactly 5 characters. Character 'P' represents a Paper throw, 'S' represents a Scissors throw, and 'R' represents a Rock throw. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | players will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of players will contain exactly 5 characters. | ||||||||||||
- | Each element of players will contain only the characters 'P', 'R' and 'S'. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|