Problem of the day
Nezuko and Zenitsu were playing Rock Paper Scissors which is a very popular game where each player can do three moves which are: ‘Rock’, ‘Paper’ and ‘Scissor’.
The winner of a game is decided in the following way:
‘Rock’ beats ‘Scissor’.
‘Scissor’ beats ‘Paper’.
‘Paper’ beats ‘Rock’.
If both players make the same move like ‘Rock’ is made by both person then that result in a draw and whose point will not be rewarded to anyone.
Now you have been provided with two strings representing the moves that they will make for ‘NEZUKO’ represents Nezuko’s string and ‘ZENITSU’ represents Zenitsu’s moves.
In the string ‘R’ represents ‘ROCK’ and ‘P’ represents ‘PAPER’ and ‘S’ represents ‘SCISSORS’.
There is a total of ‘K’ games that will be played and the player will play the move by traversing the string provided. If a player reaches the end of the string then his next moves will be played from the start of the string.
You have to tell the number of games won by Nezuko and the number of games won by Zenitsu respectively in order.
Example:Input: ‘K’ = 3, ‘NEZUKO’ = ‘RP’, ‘ZENITSU’ = ‘R’
Output: 1 0
Game 1: ‘NEZUKO’ = ‘R’, ‘ZENITSU’ = ‘R’, Result = ‘Draw’.
Game 2: ‘NEZUKO’ = ‘P’, ‘ZENITSU’ = ‘R’, Result = ‘Nezuko won the game’.
Game 3: ‘NEZUKO’ = ‘R’, ‘ZENITSU’ = ‘R’, Result = ‘Draw’.
The first line of the input contains a single integer 'T', representing the number of test cases.
For each test case:
The first line will contain the value ‘K’.
The second line will contain the string ‘NEZUKO’ representing the moves of ‘Nezuko’.
The third line will contain the string ‘ZENITSU’ representing the moves of ‘Zenitsu’.
Output format:
For each test case, print the number of games won by Nezuko and the number of games won by Zenitsu respectively in order.
Note:
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= K <= 10^5
1<= |NEZUKO| <= 10^5
1<= |ZENITSU| <= 10^5
Strings contain only 3 types of values ‘R’, ‘P’ and ‘S’.
Time Limit: 1 sec
2
3
RP
R
4
PRSP
RPSR
1 0
2 1
For test case 1:
Game 1: ‘NEZUKO’ = ‘R’, ‘ZENITSU’ = ‘R’, Result = ‘Draw’.
Game 2: ‘NEZUKO’ = ‘P’, ‘ZENITSU’ = ‘R’, Result = ‘Nezuko won the game’.
Game 3: ‘NEZUKO’ = ‘R’, ‘ZENITSU’ = ‘R’, Result = ‘Draw’.
For test case 2:
Game 1: ‘NEZUKO’ = ‘P’, ‘ZENITSU’ = ‘R’, Result = ‘Nezuko won the game’.
Game 2: ‘NEZUKO’ = ‘R’, ‘ZENITSU’ = ‘P’, Result = ‘Zenitsu won the game’.
Game 3: ‘NEZUKO’ = ‘S’, ‘ZENITSU’ = ‘S’, Result = ‘Draw’.
Game 4: ‘NEZUKO’ = ‘P’, ‘ZENITSU’ = ‘R’, Result = ‘Nezuko won the game’.
2
4
RPSPSRPSR
SPRPSRPPRSR
6
RPSPRSPS
RPS
1 1
1 1