문제 확인하기
2. 정답 코드 (Python, memory: 31256KB, time: 44ms)
def determine_winner(player1_gestures, player2_gestures):
wins_player1 = 0
wins_player2 = 0
for gesture1, gesture2 in zip(player1_gestures, player2_gestures):
if gesture1 == gesture2:
continue
if (gesture1 == 'R' and gesture2 == 'S') or (gesture1 == 'P' and gesture2 == 'R') or (gesture1 == 'S' and gesture2 == 'P'):
wins_player1 += 1
else:
wins_player2 += 1
return wins_player1, wins_player2
while True:
player1_gestures = input().strip()
player2_gestures = input().strip()
if player1_gestures == 'E' and player2_gestures == 'E':
break
wins_player1, wins_player2 = determine_winner(player1_gestures, player2_gestures)
print("P1:", wins_player1)
print("P2:", wins_player2)