Each card consists of a number and a symbol. Each player will have a set of cards and that set consist 16 cards and it has 4 types of cards named as (R, Q, P, S) and there will be 4 cards of each type numbered as (If card symbol like R then card contains details like R 1, R 2, R 3, R 4). So they started playing the game.
Initially, cards are flipped and shuffled. At the time each player can flip one card. According to the rules of card game, Score of each player depending on card types that they have got(for card R total sum of R cards will increase by multiplying by 10, similarly for Q it’s 10 and for P it’s 7 and S it’s 5), and player who got the highest score is the winner.
Find the winner of the card game.
Input format
1st input is an integer indicates a number of times each player can flip the card. (1>=n<=16).
The next line of input indicates details of the flipped card, like card name[should be b/w[R, Q, P, S] and card number[b/w 1-4].
(follow the sample input and output format).
Output format
The output consists of the total scores and status of the game.
Refer to sample input and output for formatting details.
Note: All text in bold corresponds to the input and the rest corresponds to output [Refer to sample input and output format].
Sample Input and Output 1:
Enter number of time player can flip the card
3
Arun flip the card
R
1
Arya flip the card
S
2
Arun flip the card
P
1
Arya flip the card
R
3
Arun flip the card
R
4
Arya flip the card
P
3
Total scores 57 61
Arya won the game
Sample Input and Output 2:
Enter number of time player can Flip the card
2
Arun flip the card
R
2
Arya flip the card
Q
2
Arun flip the card
P
3
Arya flip the card
S
3
Total scores 41 35
Arun won the game
Sample Input and Output 3:
Enter number of time player can flip the card
2
Arun flip the card
R
2
Arya flip the fard
P
3
Arun flip the card
P
3
Arya flip the card
Q
2
Total scores 41 41
Game tied
Solution:
print("Enter number of time player can flip the card")
n=int(input())
a=[]
b=[]
for i in range(n):
print("Arun flip the card")
a1=[]
x=input()
a1.append(x)
y=int(input())
a1.append(y)
a.append(a1)
print("Arya flip the card")
b1=[]
x1=input()
b1.append(x1)
y1=int(input())
b1.append(y1)
b.append(b1)
s1,s2=0,0
for i in a:
if i[0]=='P':
s1+=i[1]*7
elif i[0]=='Q':
s1+=i[1]*10
elif i[0]=='R':
s1+=i[1]*10
elif i[0]=='S':
s1+=i[1]*5
for i in b:
if i[0]=='P':
s2+=i[1]*7
elif i[0]=='Q':
s2+=i[1]*10
elif i[0]=='R':
s2+=i[1]*10
elif i[0]=='S':
s2+=i[1]*5
print("Total scores {} {}".format(s1,s2))
if s1>s2:
print("Arun won the game")
elif s2>s1:
print("Arya won the game")
else:
print("Game tied")