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: Wrong Answer

Solution code:
import sys
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0: # 上→奥に回転
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1: # 上→手前に回転
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2: # 上→左に回転
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3: # 上→右に回転
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        elif way == 4: # 上部を固定して反時計回りに回転
            self.t, self.s, self.e, self.w, self.n, self.b = self.t, self.w, self.s, self.n, self.e, self.b
    
    def settop(self, num):
        # num を上面に持ってくるようにする
        if num not in (self.t, self.s, self.e, self.w, self.n, self.b):
            print("unexpected error")
            sys.exit
        elif num == self.t: #最初から上面にあれば何もしない
            pass
        elif num == self.b: #底面にあれば2回回転
            self.rot(0)
            self.rot(0)
        elif num == self.n: #奥にあれば、手前に回転
            self.rot(1)
        elif num == self.s: #手前にあれば、奥に回転
            self.rot(0)
        elif num == self.e: #右にあれば、左に回転
            self.rot(2)
        elif num == self.w: #左にあれば、右に回転
            self.rot(3)
       

def main():
    t1,s1,e1,w1,n1,b1 = map(int, input().split())
    t2,s2,e2,w2,n2,b2 = map(int, input().split())

    dice1 = Dice(t1,s1,e1,w1,n1,b1)
    dice2 = Dice(t2,s2,e2,w2,n2,b2)

    #dice2を回転して、dice1に一致するか調べる。
    dice2.settop(dice1.t)
    flag = 0
    for _ in range(4):
        if (dice1.t, dice1.s, dice1.e, dice1.w, dice1.n, dice1.b) == (dice2.t, dice2.s, dice2.e, dice2.w, dice2.n, dice2.b):
            flag = 1
            break
        else:
            dice2.rot(4)

    if flag == 1:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,num):
        self.num = num.copy()
        
    def east(self):
        temp = self.num.copy()
        self.num[1-1] = temp[4-1]
        self.num[4-1] = temp[6-1]
        self.num[6-1] = temp[3-1]
        self.num[3-1] = temp[1-1]

    def north(self):
        temp = self.num.copy()
        self.num[1-1] = temp[2-1]
        self.num[2-1] = temp[6-1]
        self.num[6-1] = temp[5-1]
        self.num[5-1] = temp[1-1]

    def south(self):
        temp = self.num.copy()
        self.num[1-1] = temp[5-1]
        self.num[5-1] = temp[6-1]
        self.num[6-1] = temp[2-1]
        self.num[2-1] = temp[1-1]

    def west(self):
        temp = self.num.copy()
        self.num[1-1] = temp[3-1]
        self.num[3-1] = temp[6-1]
        self.num[6-1] = temp[4-1]
        self.num[4-1] = temp[1-1]

    def right(self):
        temp = self.num.copy()
        self.num[2-1] = temp[4-1]
        self.num[4-1] = temp[5-1]
        self.num[5-1] = temp[3-1]
        self.num[3-1] = temp[2-1]

num1 = list(map(int,input().split()))
num2 = list(map(int,input().split()))
dice1,dice2 = Dice(num1),Dice(num2)
if num1.sort() != num2.sort(): print('No')
else:      
    while not (dice2.num[0] == dice1.num[0] or dice2.num[1] == dice1.num[1]): dice2.north()
    while dice2.num[0] != dice1.num[0]: dice2.east()
    while dice2.num[1] != dice1.num[1]: dice2.right()
    
    for i in range(6):
        if dice2.num[i] != dice1.num[i]:
            print('No')
            break
    else: print('Yes')

Submission status: Wrong Answer

Solution code:
c1=[int(i) for i in input().split()]
c2=[int(i) for i in input().split()]
d=[(0,0,1),(-1,0,0),(0,1,0),(0,-1,0),(1,0,0),(0,0,-1)]
def north(r):
    res=[]
    for p in r:
        res.append((p[2],p[1],-p[0]))
    return res
def south(r):
    res=[]
    for p in r:
        res.append((-p[2],p[1],p[0]))
    return res
def east(r):
    res=[]
    for p in r:
        res.append((p[0],p[2],-p[1]))
    return res
def west(r):
    res=[]
    for p in r:
        res.append((p[0],-p[2],p[1]))
    return res
def crosspro(y,x):
    return (y[1]*x[2]-y[2]*x[1],y[2]*x[0]-y[0]*x[2],y[0]*x[1]-y[1]*x[0])
P=[-1 for i in range(6)]
D1=dict()
for i in range(6):
    D1[c1[i]]=i
for i in range(6):
    P[i]=D1[c2[i]]
#print(P)
if min(P)==-1:
    print("No")
    exit()
for i in range(6):
    for j in range(6):
        if i==j:
            continue
        if D1[c1[i]]+D1[c1[j]]==5:
            continue
        #print(i,j)
        z1=crosspro(d[i],d[j])
        z2=crosspro(d[P[i]],d[P[j]])
        #print(z1,z2)
        k1=-1
        k2=-1
        for _ in range(6):
            if d[_]==z1:
                k1=_
            if d[_]==z2:
                k2=_
        if c1[k1]!=c2[k2]:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
P=[-1 for i in range(6)]
for i in range(6):
    for j in range(6):
        if a[i]==b[j]:
            P[i]=j
if min(P)==-1:
    print("No")
for i in range(3):
    if P[i]+P[5-i]!=5:
        print("No")
        exit()
l=0
for i in range(6):
    for j in range(6):
        if i<j:
            if P[i]>P[j]:
                l+=1
if l%2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
P=[-1 for i in range(6)]
if len(set(a))==2:
    print("Yes")
    exit()
for i in range(6):
    for j in range(6):
        if a[i]==b[j]:
            P[i]=j
if min(P)==-1:
    print("No")
for i in range(3):
    if P[i]+P[5-i]!=5:
        print("No")
        exit()
l=0
for i in range(6):
    for j in range(6):
        if i<j:
            if P[i]>P[j]:
                l+=1
if l%2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
dice_1 = input().split()
dice_2 = input().split()

rolls = {'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
q_1 = dice_2.index(dice_1[0])
if q_1 == 0:
    order = ''
elif q_1 == 1:
    order = 'N'
elif q_1 == 2:
    order = 'W'
elif q_1 == 3:
    order = 'E'
elif q_1 == 4:
    order = 'S'
elif q_1 == 5:
    order = 'SS'
for d in order:
    roll = rolls[d]
    dice_2 = [dice_2[i] for i in roll]

if dice_2[5] == dice_1[5]:
    l = [1, 2, 4, 3]
    if ' '.join([dice_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
dice_1 = input().split()
dice_2 = input().split()

rolls = {' ':[0, 1, 2, 3, 4, 5], 
         'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
orders = [' ', 'N', 'W', 'E', 'S', 'SS']
tf = 0
for order in orders:
    for d in order:
        roll = rolls[d]
        copy_2 = [dice_2[i] for i in roll]
    
    l = [1, 2, 4, 3]
    a0 = copy_2[0] == dice_1[0]
    a1 = copy_2[5] == dice_1[5]
    a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)
    if  a0 and a1 and a2:
        tf += 1
    else:
        print(order)
        print(dice_1)
        print(copy_2)

if tf>0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
dice_1 = input().split()
dice_2 = input().split()

rolls = {' ':[0, 1, 2, 3, 4, 5], 
         'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
orders = [' ', 'N', 'W', 'E', 'S', 'SS']
tf = 0
for order in orders:
    for d in order:
        roll = rolls[d]
        copy_2 = [dice_2[i] for i in roll]
    
    l = [1, 2, 4, 3]
    a0 = copy_2[0] == dice_1[0]
    a1 = copy_2[5] == dice_1[5]
    a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)
    if  a0 and a1 and a2:
        tf += 1
#    else:
#        print(order)
#        print(dice_1)
#        print(copy_2)

if tf>0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from typing import List


class Dice:

    def __init__(self, values: List[int]):
        self.face_value = values

    def get_value(self, face_num) -> int:
        return self.face_value[face_num]

    def get_all_values(self) -> str:
        return ' '.join(map(str, self.face_value))

    def invoke_method(self, mkey: str) -> None:
        if mkey == 'S':
            self.S()
        elif mkey == 'N':
            self.N()
        elif mkey == 'E':
            self.E()
        elif mkey == 'W':
            self.W()
        else:
            raise ValueError(f'This method does not exist. : {mkey}')

    def set_value(self, s0, s1, s2, s3, s4, s5) -> None:
        self.face_value[0] = s0
        self.face_value[1] = s1
        self.face_value[2] = s2
        self.face_value[3] = s3
        self.face_value[4] = s4
        self.face_value[5] = s5

    def S(self) -> None:
        self.set_value(self.face_value[4], self.face_value[0],
                       self.face_value[2], self.face_value[3],
                       self.face_value[5], self.face_value[1])

    def N(self) -> None:
        self.set_value(self.face_value[1], self.face_value[5],
                       self.face_value[2], self.face_value[3],
                       self.face_value[0], self.face_value[4])

    def E(self) -> None:
        self.set_value(self.face_value[3], self.face_value[1],
                       self.face_value[0], self.face_value[5],
                       self.face_value[4], self.face_value[2])

    def W(self) -> None:
        self.set_value(self.face_value[2], self.face_value[1],
                       self.face_value[5], self.face_value[0],
                       self.face_value[4], self.face_value[3])


# 提出用
data1 = [int(i) for i in input().split()]
data2 = [int(i) for i in input().split()]

# # 動作確認用1
# with open('input_itp1_11_c_1.txt', mode='r', encoding='utf8') as fin:
#     data1 = [int(i) for i in next(fin).split()]
#     data2 = [int(i) for i in next(fin).split()]

# # 動作確認用2
# with open('input_itp1_11_c_2.txt', mode='r', encoding='utf8') as fin:
#     data1 = [int(i) for i in next(fin).split()]
#     data2 = [int(i) for i in next(fin).split()]

dice1 = Dice(data1)
dice2 = Dice(data2)

for _i in range(4):
    dice1.S()
    if dice1.get_all_values() == dice2.get_all_values():
        print('Yes')
        sys.exit()

for _i in range(4):
    dice1.E()
    if dice1.get_all_values() == dice2.get_all_values():
        print('Yes')
        sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
from typing import List


class Dice:

    def __init__(self, values: List[int]):
        self.face_value = values

    def get_value(self, face_num) -> int:
        return self.face_value[face_num]

    def get_all_values(self) -> str:
        return ' '.join(map(str, self.face_value))

    def get_upper_value(self) -> int:
        return self.get_value(0)

    def invoke_method(self, mkey: str) -> None:
        if mkey == 'S':
            self.S()
        elif mkey == 'N':
            self.N()
        elif mkey == 'E':
            self.E()
        elif mkey == 'W':
            self.W()
        else:
            raise ValueError(f'This method does not exist. : {mkey}')

    def set_value(self, s0, s1, s2, s3, s4, s5) -> None:
        self.face_value[0] = s0
        self.face_value[1] = s1
        self.face_value[2] = s2
        self.face_value[3] = s3
        self.face_value[4] = s4
        self.face_value[5] = s5

    def S(self) -> None:
        self.set_value(self.face_value[4], self.face_value[0],
                       self.face_value[2], self.face_value[3],
                       self.face_value[5], self.face_value[1])

    def N(self) -> None:
        self.set_value(self.face_value[1], self.face_value[5],
                       self.face_value[2], self.face_value[3],
                       self.face_value[0], self.face_value[4])

    def E(self) -> None:
        self.set_value(self.face_value[3], self.face_value[1],
                       self.face_value[0], self.face_value[5],
                       self.face_value[4], self.face_value[2])

    def W(self) -> None:
        self.set_value(self.face_value[2], self.face_value[1],
                       self.face_value[5], self.face_value[0],
                       self.face_value[4], self.face_value[3])

    def R(self) -> None:
        """横回転."""
        self.set_value(self.face_value[0], self.face_value[2],
                       self.face_value[4], self.face_value[1],
                       self.face_value[3], self.face_value[5])


def check_R(dice1, dice2) -> bool:
    """横回転をチェックする."""
    for _i in range(4):
        dice1.R()
        if dice1.get_all_values == dice2.get_all_values():
            return True
    return False


# 提出用
data1 = [int(i) for i in input().split()]
data2 = [int(i) for i in input().split()]

# # 動作確認用1
# with open('input_itp1_11_c_3.txt', mode='r', encoding='utf8') as fin:
#     data1 = [int(i) for i in next(fin).split()]
#     data2 = [int(i) for i in next(fin).split()]

dice1 = Dice(data1)
dice2 = Dice(data2)


for _i in range(4):
    dice1.S()
    if dice1.get_upper_value() == dice2.get_upper_value():
        if check_R:
            print('Yes')
            sys.exit()

for _i in range(4):
    dice1.E()
    if dice1.get_upper_value() == dice2.get_upper_value():
        if check_R:
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
from copy import deepcopy
import queue

class Dice:
    def __init__(self, nums):
        self.labels = [None] + [ nums[i] for i in range(6) ]
        self.pos = {
            "E" : 3,
            "W" : 4,
            "S" : 2,
            "N" : 5,
            "T" : 1,
            "B" : 6
        }

    def rolled(dice, queries):
        d = deepcopy(dice)
        for q in queries:
            if q == "E":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["W"], d.pos["T"], d.pos["E"], d.pos["B"]
            elif q == "W":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["E"], d.pos["B"], d.pos["W"], d.pos["T"]
            elif q == "S":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["N"], d.pos["T"], d.pos["S"], d.pos["B"]
            elif q == "N":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["S"], d.pos["B"], d.pos["N"], d.pos["T"]
        else:
            return d

d1_nums = [int(x) for x in stdin.readline().rstrip().split()]
d2_nums = [int(x) for x in stdin.readline().rstrip().split()]
if set(d1_nums) != set(d2_nums):
    print("No")

d1 = Dice(d1_nums)
d2 = Dice(d2_nums)

# TとSに対応するクエリを記憶し, resをすぐに呼び出せるようにする
memo = [[False] * 7 for i in range(7)]
memo[d1.pos["T"]][d1.pos["S"]] = ""

# クエリとさいころd1の状態を記憶
res = {}

# BFSで探索, 今回は目の数字が同一である可能性があるため全探索
# ただし, T, S, Eがd2と同一のもののみresに登録
# diceの中身をいじってはならない
def solve(dice=d1):
    que = queue.Queue()
    que.put(dice)
    sol_q = ["E", "N", "S", "W"]
    
    while not que.empty():
        d = que.get()
        for i in sol_q:
            d_next = Dice.rolled(d, i)
            if memo[d_next.pos["T"]][d_next.pos["S"]] == False:
                que.put(d_next)
                memo[d_next.pos["T"]][d_next.pos["S"]] = memo[d.pos["T"]][d.pos["S"]] + i
                for j in ["T", "S", "E"]:
                    if d_next.labels[d_next.pos[j]] != d2.labels[d2.pos[j]]:
                        break
                else:
            	    res[memo[d_next.pos["T"]][d_next.pos["S"]]] = d_next
    else:
        return True

solve()
check_pos = ["N", "W", "B"]
if len(res) == 0:
	print("No")
else:
    for k, v in res.items():
        for i in check_pos:
            if v.labels[v.pos[i]] != d2.labels[d2.pos[i]]:
                break
        else:
            print("Yes")
            break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
class Dice:
  def make_dice(self, value):
    self.face = value
  def move(self, direc):
    if direc == "N":
      self.face = [self.face[1], self.face[5], self.face[2], self.face[3], self.face[0], self.face[4]]
      return self.face
    elif direc == "E":
      self.face = [self.face[3], self.face[1], self.face[0], self.face[5], self.face[4], self.face[2]]
      return self.face
    elif direc == "S":
      self.face = [self.face[4], self.face[0], self.face[2], self.face[3], self.face[5], self.face[1]]
      return self.face
    elif direc == "W":
      self.face = [self.face[2], self.face[1], self.face[5], self.face[0], self.face[4], self.face[3]]
      return self.face
  def get_face(self, top):
    if top == self.face[0]:
      return self.face
    elif top == self.face[1]:
      return self.move("N")
    elif top == self.face[2]:
      return self.move("W")
    elif top == self.face[3]:
      return self.move("E")
    elif top == self.face[4]:
      return self.move("S")
    elif top == self.face[5]:
      self.move("N")
      return self.move("N")
  def second_face(self, face1):
    for i in range(4):
      if face1 == self.face[1]:
        return self.face
      else:
        self.face[1],self.face[2],self.face[4],self.face[3] = self.face[2],self.face[4],self.face[3],self.face[1]

num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
dice1 = Dice()
dice2 = Dice()
dice1.make_dice(num1)
dice2.make_dice(num2)
dice2.get_face(dice1.face[0])
dice2.second_face(dice1.face[1])
if dice1.face == dice2.face:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import random

class Dice:
    def __init__(self, top, s, e, w, n, bottom):
        self.top    = top
        self.s      = s
        self.e      = e
        self.w      = w
        self.n      = n
        self.bottom = bottom

    def rotate(self, dist):
        if dist == 'N':
            self.top, self.s, self.n, self.bottom = self.s, self.bottom, self.top, self.n 
        elif dist == 'S':
            self.s, self.bottom, self.top, self.n = self.top, self.s, self.n, self.bottom 
        elif dist == 'E':
            self.top, self.e, self.w, self.bottom = self.w, self.top, self.bottom, self.e 
        elif dist == 'W':
            self.w, self.top, self.bottom, self.e = self.top, self.e, self.w, self.bottom 

if __name__ == '__main__':
    dice1 = Dice(*map(int, raw_input().split()))
    dice2 = Dice(*map(int, raw_input().split()))

    ref1 = dict()
    ref2 = dict()
    for _ in range(100):
        ref1[(dice1.top, dice1.s)] = dice1.e
        ref2[(dice2.top, dice2.s)] = dice2.e

        dist = 'NSEW'[random.randint(0,3)]
        dice1.rotate(dist)
        dice2.rotate(dist)

    print 'Yes' if ref1==ref2 else 'No'

Submission status: Wrong Answer

Solution code:
d1=list(map(int,input().split()))
d2=list(map(int,input().split()))

for i in range(4):
	d2[0],d2[1],d2[4],d2[5]=d2[1],d2[5],d2[0],d2[4]
	if d1[0]==d2[0]:
		break
if d1[0]!=d2[0]:
	for i in range(4):
		d2[0],d2[3],d2[5],d2[2]=d2[3],d2[5],d2[2],d2[0]
		if d1[0]==d2[0]:
			break
for i in range(4):
	d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
	if d1[1]==d2[1]:
		break
if d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
d1=list(map(int,input().split()))
d2=list(map(int,input().split()))
n=0

for i in range(4):
	d2[0],d2[1],d2[4],d2[5]=d2[1],d2[5],d2[0],d2[4]
	for i in range(4):
		d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
		if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
			n+=1
		else:
			for i in range(4):
				d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
				if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
					n+=1
if n==0:
	print('No')
elif n>0:
	print('Yes')

Submission status: Wrong Answer

Solution code:
import copy


class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    def __eq__(self, other):
        if other is None or not isinstance(other, Dice):
            return False
        elif self.eyes == other.eyes:
            return True

        dup = copy.copy(self)
        roll_plan = 'EEENEEENEEEN'

        for direction in roll_plan:
            dup.roll(direction)
            if other.eyes == dup.eyes:
                return True

        return False

    @property
    def eyes(self):
        return self._eyes[1:6]

    def roll(self, direction):
        a = self._eyes
        if direction == 'N':
            self._eyes = ['dummy', a[2], a[6], a[3], a[4], a[1], a[5]]
        elif direction == 'S':
            self._eyes = ['dummy', a[5], a[1], a[3], a[4], a[6], a[2]]
        elif direction == 'W':
            self._eyes = ['dummy', a[3], a[2], a[6], a[1], a[5], a[4]]
        elif direction == 'E':
            self._eyes = ['dummy', a[4], a[2], a[1], a[6], a[5], a[3]]
        else:
            raise ValueError('NEWS箱推し')


dice1 = Dice(input().split())
dice2 = Dice(input().split())
if dice1 == dice2:
    result = 'Yes'
else:
    result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
import copy


class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    def __eq__(self, other):
        if other is None or not isinstance(other, Dice):
            return False
        elif self.eyes == other.eyes:
            return True

        dup = copy.copy(self)
        roll_plan = 'EEEENEEEENEEEENEEEE'

        for direction in roll_plan:
            dup.roll(direction)
            if other.eyes == dup.eyes:
                return True

        return False

    @property
    def eyes(self):
        return self._eyes[1:6]

    def roll(self, direction):
        a = self._eyes
        if direction == 'N':
            self._eyes = ['dummy', a[2], a[6], a[3], a[4], a[1], a[5]]
        elif direction == 'S':
            self._eyes = ['dummy', a[5], a[1], a[3], a[4], a[6], a[2]]
        elif direction == 'W':
            self._eyes = ['dummy', a[3], a[2], a[6], a[1], a[5], a[4]]
        elif direction == 'E':
            self._eyes = ['dummy', a[4], a[2], a[1], a[6], a[5], a[3]]
        else:
            raise ValueError('NEWS箱推し')


dice1 = Dice(input().split())
dice2 = Dice(input().split())
if dice1 == dice2:
    result = 'Yes'
else:
    result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
import copy


class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    def __eq__(self, other):
        if other is None or not isinstance(other, Dice):
            return False

        dups = []
        for _ in range(6):
            dups.append(copy.copy(self))
        dups[1].roll('N')
        dups[2].roll('E')
        dups[3].roll('W')
        dups[4].roll('S')
        dups[5].roll('NN')

        for dup in dups:
            for _ in range(4):
                dup.roll('N')
                if other.eyes == dup.eyes:
                    return True

        return False

    @property
    def eyes(self):
        return self._eyes[1:6]

    def roll(self, direction_text):
        for d in direction_text:
            self.roll_once(d)

    def roll_once(self, direction):
        a = self._eyes
        if direction == 'N':
            self._eyes = ['dummy', a[2], a[6], a[3], a[4], a[1], a[5]]
        elif direction == 'S':
            self._eyes = ['dummy', a[5], a[1], a[3], a[4], a[6], a[2]]
        elif direction == 'W':
            self._eyes = ['dummy', a[3], a[2], a[6], a[1], a[5], a[4]]
        elif direction == 'E':
            self._eyes = ['dummy', a[4], a[2], a[1], a[6], a[5], a[3]]
        else:
            raise ValueError('NEWS箱推し')


dice1 = Dice(input().split())
dice2 = Dice(input().split())
if dice1 == dice2:
    result = 'Yes'
else:
    result = 'No'
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# coding: utf-8
import random


class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1)}
    way = ("N","E","W","S")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare(self, dice2):
        ok = False
        for i in range(1000):
            check = True
            for i2 in range(6):
                if self.label[i2] == dice2.label[i2] :
                    continue
                else:
                    check = False
                    break

            if check :
                ok = True
                break
            else:
                self.move(self.way[random.randint(0,3)])
        return ok

dice1 = Dice(input().split())
dice2 = Dice(input().split())

if dice1.compare(dice2) :
    print ("OK")
else:
    print ("NG")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# coding: utf-8
import random


class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}

    way = ("N","E","W","S","CW")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare_6sq(self, dice2):
        check = True
        for i in range(6):
            if self.label[i] == dice2.label[i] :
                continue
            else:
                check = False
                break

        return check
    
    def move_top_is(self,label):
        order = ("N","E","N","E","N")
        check = (self.get_up() == label)
        if check :
            return
        for s in order:
            self.move(s)
            check = (self.get_up() == label)
            if check:
                return


    def compare(self, dice2):
        ok = False
        self.move_top_is(dice2.get_up())
        for i in range(4):
            self.move("CW")
            if self.compare_6sq(dice2) :
                ok =True
                break
        return ok

dice1 = Dice(input().split())
dice2 = Dice(input().split())

if dice1.compare(dice2) :
    print ("OK")
else:
    print ("NG")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# coding: utf-8
import random


class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}

    way = ("N","E","W","S","CW")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare_6sq(self, dice2):
        check = True
        for i in range(6):
            if self.label[i] == dice2.label[i] :
                continue
            else:
                check = False
                break

        return check
    
    def move_top_is(self,label):
        order = ("N","E","N","E","N")
        check = (self.get_up() == label)
        if check :
            return
        for s in order:
            self.move(s)
            check = (self.get_up() == label)
            if check:
                return


    def compare(self, dice2):
        ok = False
        self.move_top_is(dice2.get_up())
        for i in range(4):
            self.move("CW")
            if self.compare_6sq(dice2) :
                ok =True
                break
        return ok

dice1 = Dice(input().split())
dice2 = Dice(input().split())

if dice1.compare(dice2) :
    print ("Yes")
else:
    print ("No")

Submission status: Wrong Answer

Solution code:
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]

def set_top(dice, top):
    return [dice[i] for i in mask[top]]

def twist(dice):
    return [dice[i] for i in (0, 3, 1, 4, 2, 5)]

def equal(dice1, dice2):
    dice2 = set_top(dice2, dice1.index(dice2[0]))
    for _ in range(4):
        if dice1 == dice2:
            return True
        dice2 = twist(dice2)
    return False
        
dice1 = input().split()
dice2 = input().split()

print('Yes' if equal(dice1, dice2) else 'No')

Submission status: Wrong Answer

Solution code:

IDX_TBL = \
{1:[2,3,5,4],
 2:[3,1,4,6],
 3:[1,2,6,5],
 4:[1,5,6,2],
 5:[1,3,6,4],
 6:[2,4,5,3]}

l1=["-"] + raw_input().split(" ")
l2=["-"] + raw_input().split(" ")

if l1[1] not in l2:
    print "No"
else:
    idx = l2.index(l1[1])
    nums1 = "".join([l1[i] for i in IDX_TBL[1]])
    nums2 = "".join([l2[i] for i in IDX_TBL[idx]])

    if nums2 in nums1*2:
        print "Yes"
    else:
        print "No"