Problem:


じゃんけん

 仲良し 5 人組でじゃんけんをすることになりました。じゃんけんとは、グー、チョキ、パーという 3つの手があり、グーとチョキの勝負ならグーが「勝ち」・チョキが「負け」、チョキとパーなら、チョキが「勝ち」・パーが「負け」、パーとグーならパーが「勝ち」・グーが「負け」というルールです。全員が同じ手、またはグー、チョキ、パー全てが出た場合は「あいこ」となります。

 5 人のじゃんけんの手を入力とし、それぞれの人の勝敗を出力するプログラムを作成してください。じゃんけんの手は、グーは 1、チョキは 2、パーは 3 の数字で表します。勝敗は「勝ち」を 1、「負け」を 2、「あいこ」を 3 の数字で表し、入力順に従って出力します。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットは以下の形式で与えられます。

h1
h2
h3
h4
h5

i 行目に i  人目の手 hi (1, 2 または 3) が与えられます。

データセットの数は 200 を超えません。

Output

入力データセットごとに、5 人の勝敗を出力します。i 行目に i 人目の勝敗(1, 2 または 3) を出力してください。

Sample Input

1
2
3
2
1
1
2
2
2
1
0

Output for the Sample Input

3
3
3
3
3
1
2
2
2
1



Sample input:
1
2
3
2
1
1
2
2
2
1
0


Sample output:
3
3
3
3
3
1
2
2
2
1

Submission status: Accepted

Solution code:
while 1:
    hands = []
    h = int(input())
    if h == 0:
        break
    hands.append(h)

    for _ in range(4):
        h = int(input())
        hands.append(h)

    h_uni = list(set(hands))
    if len(h_uni) != 2:
        for _ in range(5):
            print(3)
        continue

    h_uni.sort()
    if h_uni[0] == 1 and h_uni[1] == 2:
        for h in hands:
            if h == 1:
                print(1)
            else:
                print(2)
    elif h_uni[0] == 1 and h_uni[1] == 3:
        for h in hands:
            if h == 1:
                print(2)
            else:
                print(1)
    else:
        for h in hands:
            if h == 2:
                print(1)
            else:
                print(2)

Submission status: Accepted

Solution code:
while True:
    h1 = int(input())
    if h1 == 0:
        break
    h = [h1, *map(int, (input() for _ in [0]*4))]
    s = set(h)
    if len(s) % 2 == 1:
        print(*([3]*5), sep="\n")
    else:
        result = [0, 0, 0, 0]
        if 1 in s and 2 in s:
            result[1], result[2] = 1, 2
        elif 2 in s and 3 in s:
            result[2], result[3] = 1, 2
        else:
            result[1], result[3] = 2, 1
        print(*(result[n] for n in h), sep="\n")

Submission status: Accepted

Solution code:
a = []
while(True):
    n = int(input())
    if n == 0:
        break
    a.append(n)
    if len(a) == 5:
        uni = set(a)
        if len(uni) == 2 and 1 in uni and 2 in uni:
            for b in a: print(2 if b == 2 else 1)
        elif len(uni) == 2 and 2 in uni and 3 in uni:
            for b in a: print(2 if b == 3 else 1)
        elif len(uni) == 2 and 3 in uni and 1 in uni:
            for b in a: print(2 if b == 1 else 1)
        else:
            for _ in range(5): print(3)
        a = []

Submission status: Runtime Error

Solution code:
from sys import stdin
readline = stdin.readline


R, S, P = 1, 2, 3
W, L, D = 1, 2, 3

rps = {
    (R, S, P):{R:D, S:D, P:D},
    (R, S)   :{R:W, S:L},
    (S, P)   :{S:W, P:L},
    (R, P)   :{P:W, R:L}
}

while True:
    hand = int(readline())
    if hand == 0:
        break
    hands = [hand] + [int(readline()) for _ in range(4)]
    hand_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hand_set][h])

Submission status: Runtime Error

Solution code:
from sys import stdin
readline = stdin.readline


def main():
    R, S, P = 1, 2, 3
    W, L, D = 1, 2, 3

    rps = {
        (R, S, P):{R:D, S:D, P:D},
        (R, S)   :{R:W, S:L},
        (S, P)   :{S:W, P:L},
        (R, P)   :{P:W, R:L}
    }

    while True:
        hand = int(readline())
        if hand == 0:
            break
        hands = [hand] + [int(readline()) for _ in range(4)]
        hand_set = tuple(sorted(set(hands)))
        for h in hands:
            print(rps[hand_set][h])
main()

Submission status: Runtime Error

Solution code:
from sys import stdin
readline = stdin.readline

def main():
    R, S, P = 1, 2, 3
    W, L, D = 1, 2, 3

    rps = {
        (R, S, P):{R:D, S:D, P:D},
        (R, S)   :{R:W, S:L},
        (S, P)   :{S:W, P:L},
        (R, P)   :{P:W, R:L}
    }

    while True:
        try:
            hands = [int(readline()) for _ in range(5)]
        except:
            break
        hand_set = tuple(sorted(set(hands)))
        for h in hands:
            print(rps[hand_set][h])
main()

Submission status: Runtime Error

Solution code:
from sys import stdin
readline = stdin.readline

from io import StringIO
readline = StringIO('''1
2
3
2
1
1
2
2
2
1
0''').readline

R, S, P = 1, 2, 3  # rock, scissors, paper
W, L, D = 1, 2, 3  # win, lose, draw


while True:
    hands = []
    hands.append(int(readline()))
    if hands[0] == 0:
        break
    for _ in range(4):
        hands.append(int(readline()))

    hands_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hands_set][h])

Submission status: Runtime Error

Solution code:
while True:
    h1= int(input())
    if h1== 0:
        break
    h2,h3,h4,h5= [int(input()) for _ in range(4)]
    l= [h1,h2,h3,h4,h5]
    if 1 and 2 and 3 in l:
        for _ in range(5): print("3")
    else:
        for i in range(5):
            if l[i]==1:
                print('1' if 2 in l '2')
            elif l[i]==2:
                print('1' if 3 in l '2')
            else:
                print('1' if 1 in l '2')