Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice III

  Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Input

  In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.

    In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

  Print "Yes" if two dices are identical, otherwise "No" in a line.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes

Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No



Sample input:
1 2 3 4 5 6
6 2 4 3 5 1


Sample output:
Yes

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0235',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g+=g
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d = input().split()
a = input().split()
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
t, f = d.index(a[0]), d.index(a[1])
r = p[t][f]
l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
print("Yes") if a == l else print("No")

Submission status: Runtime Error

Solution code:
d = input().split()
a = input().split()
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
ts = [i for i, x in enumerate(d) if x == a[0]]
fs = [i for i, x in enumerate(d) if x == a[1]]
b = 0
for t in ts:
  for f in fs:
    if t == f: continue
    r = p[t][f]
    l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
    if a == l: b += 1; break
print("Yes") if b > 0 else print("No")

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self):
        self.side = {"top": 0, "front": 0, "right": 0, "left": 0, "back": 0, "bottom": 0}

    # サイコロを東西南北、どちらか一方に転がした時、それぞれの面の変化
    def roll(self, direction):
        self.direction = direction
        if self.direction == "N":
            w = self.side["top"]
            self.side["top"] = self.side["front"]
            self.side["front"] = self.side["bottom"]
            self.side["bottom"] = self.side["back"]
            self.side["back"] = w
        elif self.direction == "S":
            w = self.side["top"]
            self.side["top"] = self.side["back"]
            self.side["back"] = self.side["bottom"]
            self.side["bottom"] = self.side["front"]
            self.side["front"] = w
        elif self.direction == "E":
            w = self.side["top"]
            self.side["top"] = self.side["left"]
            self.side["left"] = self.side["bottom"]
            self.side["bottom"] = self.side["right"]
            self.side["right"] = w
        elif self.direction == "W":
            w = self.side["top"]
            self.side["top"] = self.side["right"]
            self.side["right"] = self.side["bottom"]
            self.side["bottom"] = self.side["left"]
            self.side["left"] = w

    # サイコロの面の位置関係
    def position_relation(self, top, front):
        # 右面が"right"の場合
        if top == "top" and front == "front"\
        or top == "front" and front == "bottom"\
        or top == "bottom" and front == "back"\
        or top == "back" and front == "top":
            self.right = self.side["right"]
        # 右面が"left"の場合 
        if top == "top" and front == "back"\
        or top == "back" and front == "bottom"\
        or top == "bottom" and front == "front"\
        or top == "front" and front == "top":
            self.right = self.side["left"]
        # 右面が"back"の場合
        if top == "top" and front == "right"\
        or top == "right" and front == "bottom"\
        or top == "bottom" and front == "left"\
        or top == "left" and front == "top":
            self.right = self.side["back"]
        # 右面が"front"の場合
        if top == "top" and front == "left"\
        or top == "left" and front == "bottom"\
        or top == "bottom" and front == "right"\
        or top == "right" and front == "top":
            self.right = self.side["front"]
        # 右面が"top"の場合
        if top == "front" and front == "right"\
        or top == "right" and front == "back"\
        or top == "back" and front == "left"\
        or top == "left" and front == "front":
            self.right = self.side["top"]
        # 右面が"bottom"の場合
        if top == "front" and front == "left"\
        or top == "left" and front == "back"\
        or top == "back" and front == "right"\
        or top == "right" and front == "front":
            self.right = self.side["bottom"]

# １つ目のサイコロの初期化
dice = Dice()
for s, n in zip(dice.side, input().split()):
    dice.side[s] = int(n)

# １つ目のサイコロの"top","front"の面が２つ目のサイコロのどの面に移ったか調べ、位置関係から右面の値を求める。
a = [int(i) for i in input().split()]
for k, v in dice.side.items():
    if a[0] == v:
        top = k
    if a[1] == v:
        front = k
dice.position_relation(top, front)

if dice.right == a[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
set_first = [
    [1,2,3,4,5,6],
    [5,1,3,4,6,2],
    [4,2,1,6,5,3],
    [3,2,6,1,5,4],
    [2,6,3,4,1,5],
    [6,5,3,4,2,1]]

set_rotate = [
    ['dummy'],
    [1,2,3,4,5,6],
    [1,4,2,5,3,6],
    [1,3,5,2,4,6],
    [1,5,4,3,2,6]]

rotate = lambda dice, order: [dice[order[i]-1] for i in range(6)]

def set_dice(dice):
    i = dice.index(1)
    ret = rotate(dice, set_first[i])
    j = ret.index(2)
    if j == 5:
        j = ret.index(3)
    ret = rotate(ret, set_rotate[j])
    return ''.join(map(str,ret))
   
dice_1 = list(map(int, input().split()))
dice_1s = set_dice(dice_1)

dice_2 = list(map(int, input().split()))
dice_2s = set_dice(dice_2)

if dice_1s == dice_2s:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
set_first = [
    [1,2,3,4,5,6],
    [5,1,3,4,6,2],
    [4,2,1,6,5,3],
    [3,2,6,1,5,4],
    [2,6,3,4,1,5],
    [6,5,3,4,2,1]]

set_rotate = [
    ['dummy'],
    [1,2,3,4,5,6],
    [1,4,2,5,3,6],
    [1,3,5,2,4,6],
    [1,5,4,3,2,6]]

rotate = lambda dice, order: [dice[order[i]-1] for i in range(6)]

def set_dice(dice):
    i = dice.index(min(dice))
    ret = rotate(dice, set_first[i])
    j = ret.index(min(ret[1:]))
    if j == 5:
        j = ret.index(min(ret[1:5]))
    ret = rotate(ret, set_rotate[j])
    return '-'.join(map(str,ret))
   
dice_1 = list(map(int, input().split()))
dice_1s = set_dice(dice_1)

dice_2 = list(map(int, input().split()))
dice_2s = set_dice(dice_2)

if dice_1s == dice_2s:
    print('Yes')
else:
    print('No')