9
0
You decided to organize a rock-paper-scissors championship to find out who is the best. You don't want to let luck to decide the winner so everyone has to give you his or her tactic in writing before the competition. You also like simple things so a move of a competitor (showing rock, paper or scissors) has to be based only the previous turn (RvR, RvP, RvS, PvR, PvP, PvS, SvR, SvP or SvS). In the first turn a player has to show a fixed sign.
You decided to write a program (or function) to simulate the championship.
Details of the competition
- There will be at least 2 contestants.
- Every player plays exactly one match with everyone else.
- One match lasts 7 rounds.
- In every round the winner gets 2 points the loser gets none. In the event of a tie both player score 1 point.
- A players score in a match is the sum of his or her points over the turns of the match.
- A players final score in the championship is the sum of his or her points over all matches.
Details of the input:
- your program or function receives
N
10 character long strings each of them corresponds to a players strategy. All characters are (lowercase)r
p
ors
meaning that in the given situation the player will show rock paper or scissors. - The first letter codes the first turn (in every match for that competitor). The second shows what happens if the last round was rock vs rock. The next ones are RvP, RvS, PvR, PvP, PvS, SvR, SvP and SvS where the first letter is the player's sign and the second is the opponent's. E.g.
rrpsrpsrps
means the player starts with rock and then copies the opponent's last move. - You can input the list of strings as a list/array or similar data of your language or as one string. In the latter case some kind of separator character is a must.
Details of the output:
- Your program or function should output the final scores of each player in the same order as the input was supplied.
- Scores should be separated by spaces or newlines. Trailing space or newline is allowed.
Examples:
Input:
['rrpsrpsrps', 'rpppsprrpr']
Output:
5 9
(turns are rvr rvp pvs svp pvr rvp pvs
)
Input:
['rrpsrpsrps', 'rpppsprrpr', 'ssssssssss']
Output:
13 17 12
(matches are 5-9
(1st vs 2nd), 8-6
(1st vs 3rd) and 8-6
(2nd vs 3rd))
This is code-golf so the shortest entry wins.
Inspired by Numberphile? ;-) – Jakube – 2015-01-30T11:19:04.410
Is the second example correct? I think the 1st looses against the 3rd with
6-8
and the second looses against the third with6-8
. – Jakube – 2015-01-30T11:48:18.447@Jakube Corrected example input. Thx. – randomra – 2015-01-30T11:58:19.823