본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 21895번 Rock-Paper-Scissors for three

by 현장 2024. 1. 27.

-Code

def solution(r1, r2):
    if r1 != r2:
        if (r1 == "R" and r2 == "S") or (r1 == "S" and r2 == "R"):
            return "R"
        elif (r1 == "R" and r2 == "P") or (r1 == "P" and r2 == "R"):
            return "P"
        elif (r1 == "S" and r2 == "P") or (r1 == "P" and r2 == "S"):
            return "S"
    else:
        if r1 == "R":
            return "P"
        elif r1 == "S":
            return "R"
        elif r1 == "P":
            return "S"

n = int(input())

robot1 = input()
robot2 = input()
res = ""

for i in range(n):
    res += solution(robot1[i], robot2[i])

print(res)