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:
# -*- coding: utf-8 -*-


class Dice:
    def __init__(self, n):
        self.upper    = n[0]
        self.backward = n[1]
        self.right    = n[2]
        self.left     = n[3]
        self.ahead    = n[4]
        self.bottom   = n[5]

    def roll_north(self):
        self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom

    def roll_south(self):
        self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper

    def roll_east(self):
        self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom

    def roll_west(self):
        self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper

    def roll_side(self):
        self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward


def match_dice(dice1, dice2):
    for i in range(4):
        dice1.roll_north()

        for j in range(4):
            dice1.roll_east()

            for k in range(4):
                dice1.roll_side()

                if dice1 is dice2:
                    return 0
    return 1


dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))
result = match_dice(dice1, dice2)

if result is 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
class Saikoro:

    def sai(self,one,two,three,four,five,six):
        self.s1=int(one)
        self.s2=int(two)
        self.s3=int(three)
        self.s4=int(four)
        self.s5=int(five)
        self.s6=int(six)

    def turnE(self):
        e=[self.s4,self.s2,self.s1,self.s6,self.s5,self.s3]
        self.s1=e[0]
        self.s2=e[1]
        self.s3=e[2]
        self.s4=e[3]
        self.s5=e[4]
        self.s6=e[5]

    def turnN(self):
        n=[self.s2,self.s6,self.s3,self.s4,self.s1,self.s5]
        self.s1=n[0]
        self.s2=n[1]
        self.s3=n[2]
        self.s4=n[3]
        self.s5=n[4]
        self.s6=n[5]

l=input().split()
m=input().split()

sai1= Saikoro()
sai2= Saikoro()

sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])
sai2.sai(m[0],m[1],m[2],m[3],m[4],m[5])

Ans=[]
ichi=sai2.s1
ni=sai2.s2
san=sai2.s3
p=0
while p<4:
    if ichi==int(l[0]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[5]) or ichi==int(l[5]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[0]) :
        if san==int(l[5]):
            Ans.append("Yes")
            break
        else:
            Ans.append("No")
            break
    elif ichi==int(l[5]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[0]) or ichi==int(l[0]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[5]) :
        if san==int(l[1]):
            Ans.append("Yes")
            break
        else:
            Ans.append("No")
            break
    w=0
    sai1.turnE()
    while w<4:
        sai1.turnN()
        if sai1.s1==ichi and sai1.s2==ni:
            if sai1.s3==san:
                Ans.append("Yes")
                break
            else:
                Ans.append("No")
                break
        else:
            pass
        w+=1
    p+=1

for A in Ans:
    print(A)

Submission status: Wrong Answer

Solution code:
class Saikoro:

    def sai(self,one,two,three,four,five,six):
        self.s1=int(one)
        self.s2=int(two)
        self.s3=int(three)
        self.s4=int(four)
        self.s5=int(five)
        self.s6=int(six)

    def turnE(self):
        e=[self.s4,self.s2,self.s1,self.s6,self.s5,self.s3]
        self.s1=e[0]
        self.s2=e[1]
        self.s3=e[2]
        self.s4=e[3]
        self.s5=e[4]
        self.s6=e[5]

    def turnN(self):
        n=[self.s2,self.s6,self.s3,self.s4,self.s1,self.s5]
        self.s1=n[0]
        self.s2=n[1]
        self.s3=n[2]
        self.s4=n[3]
        self.s5=n[4]
        self.s6=n[5]

l=input().split()
m=input().split()

sai1= Saikoro()
sai2= Saikoro()

sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])
sai2.sai(m[0],m[1],m[2],m[3],m[4],m[5])


ichi=sai2.s1
ni=sai2.s2
san=sai2.s3
p=0
while p<4:
    if ichi==int(l[0]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[5]) or ichi==int(l[5]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[0]) :
        if san==int(l[5]):
            Ans="Yes"
            break
        else:
            Ans="No"
            break
    elif ichi==int(l[5]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[0]) or ichi==int(l[0]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[5]) :
        if san==int(l[1]):
            Ans="Yes"
            break
        else:
            Ans="No"
            break
    w=0
    sai1.turnE()
    while w<4:
        sai1.turnN()
        if sai1.s1==ichi and sai1.s2==ni:
            if sai1.s3==san:
                Ans="Yes"
                break
            else:
                Ans="No"
                break
        else:
            pass
        w+=1
    p+=1

print(Ans)

Submission status: Wrong Answer

Solution code:
class Saikoro:

    def sai(self,one,two,three,four,five,six):
        self.s1=int(one)
        self.s2=int(two)
        self.s3=int(three)
        self.s4=int(four)
        self.s5=int(five)
        self.s6=int(six)

    def turnE(self):
        e=[self.s4,self.s2,self.s1,self.s6,self.s5,self.s3]
        self.s1=e[0]
        self.s2=e[1]
        self.s3=e[2]
        self.s4=e[3]
        self.s5=e[4]
        self.s6=e[5]

    def turnN(self):
        n=[self.s2,self.s6,self.s3,self.s4,self.s1,self.s5]
        self.s1=n[0]
        self.s2=n[1]
        self.s3=n[2]
        self.s4=n[3]
        self.s5=n[4]
        self.s6=n[5]

l=input().split()
m=input().split()

sai1= Saikoro()
sai2= Saikoro()

sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])
sai2.sai(m[0],m[1],m[2],m[3],m[4],m[5])


ichi=sai2.s1
ni=sai2.s2
san=sai2.s3
p=0
while p<4:
    if ichi==int(l[0]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[5]) or ichi==int(l[5]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[0]) :
        if san==int(l[4]):
            Ans="Yes"
            break
        else:
            Ans="No"
            break
    elif ichi==int(l[5]) and ni==int(l[2]) or ichi==int(l[2]) and ni==int(l[0]) or ichi==int(l[0]) and ni==int(l[3]) or ichi==int(l[3]) and ni==int(l[5]) :
        if san==int(l[1]):
            Ans="Yes"
            break
        else:
            Ans="No"
            break
    w=0
    sai1.turnE()
    while w<4:
        sai1.turnN()
        if sai1.s1==ichi and sai1.s2==ni:
            if sai1.s3==san:
                Ans="Yes"
                p=4
                break
            else:
                Ans="No"
                p=4
                break
        else:
            pass
        w+=1

    p+=1

print(Ans)

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.b = b
        self.u = u
        self.a=[t,f,r,l,b,u]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d):
        self.a=[self.a[i] for i in self.direction[d]]
        self.t = self.a[0]
        self.f = self.a[1]
        self.r = self.a[2]
        self.l = self.a[3]
        self.b = self.a[4]
        self.u = self.a[5]
t,f,r,l,b,u=map(int,input().split())
dice1=Dice(t,f,r,l,b,u)
t,f,r,l,b,u=map(int,input().split())
dice2=Dice(t,f,r,l,b,u)
s='SSSWEE'
w='YYYY'
ans='No'
for j in s:
    for r in w:
        if dice1.a==dice2.a:
            ans='Yes'
            break
        dice2.roll(r)
    else:
        dice2.roll(j)
        continue
    break
print(ans)

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.b = b
        self.u = u
        self.a=[t,f,r,l,b,u]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d):
        self.a=[self.a[i] for i in self.direction[d]]
        self.t = self.a[0]
        self.f = self.a[1]
        self.r = self.a[2]
        self.l = self.a[3]
        self.b = self.a[4]
        self.u = self.a[5]
t,f,r,l,b,u=map(int,input().split())
dice1=Dice(t,f,r,l,b,u)
t,f,r,l,b,u=map(int,input().split())
dice2=Dice(t,f,r,l,b,u)
s='SSSEWW'
w='YYY'
ans='No'
for j in s:
    for r in w:
        if dice1.a==dice2.a:
            ans='Yes'
            break
        dice2.roll(r)
    else:
        dice2.roll(j)
        continue
    break
print(ans)

Submission status: Wrong Answer

Solution code:
class Dice():
    def __init__(self, numbers):
        self.top = numbers[0]
        self.s = numbers[1]
        self.e = numbers[2]
        self.w = numbers[3]
        self.n = numbers[4]
        self.bot = numbers[5]
    def rot(self, dir):
        top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.n, self.bot)
        if dir == 'N':
            self.top = s
            self.s = bot
            self.e = e
            self.w = w
            self.n = top
            self.bot = n
        elif dir == 'S':
            self.top = n
            self.s = top
            self.e = e
            self.w = w
            self.n = bot
            self.bot = s
        elif dir == 'E':
            self.top = w
            self.s = s
            self.e = top
            self.w = bot
            self.n = n
            self.bot = e
        elif dir == 'W':
            self.top = e
            self.s = s
            self.e = bot
            self.w = top
            self.n = n
            self.bot = w
    def getTop(self):
        return self.top
    def rotMany(self, command):
        for dir in command:
            self.rot(dir)



li = list(map(int, input().split()))
D1 = Dice(li)
li = list(map(int, input().split()))
D2 = Dice(li)


for cmd in ["N","N","N","E","EE",""]:
    if D1.top == D2.top:
        break
    else:
        D1.rotMany(cmd)
if D1.top != D2.top:
    print("No")
    exit(0)
for cmd in ["SEN", "SEN", "SEN", ""]:
    if D1.s == D2.s:
        break
    else:
        D1.rotMany(cmd)
if D1.s != D2.s:
    print("No")
    exit(0)
if D1.w == D2.w and D1.e == D2.e and D1.n == D2.n and D1.bot == D2.bot:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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)

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

import random
for i in range(50):
    dice.roll(random.choice("NSEW"))
    if dice.side == dice2.side:
        # print("同じ　{}".format(dice.side))
        print("Yes")
        break
    else:
        # print("違う　{}".format(dice.side))
        continue
else:
    print("No")

Submission status: Wrong Answer

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)

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

import random
for i in range(100):
    dice.roll(random.choice(["N", "S", "E", "S"]))
    if dice.side == dice2.side:
        # print(dice.direction)
        print("Yes")
        break
    else:
        # print(dice.direction)
        continue
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Dice(object):

    def __init__(self, nums):
        self.nums = nums
        self.pos = ['23452345', '14631463', '12651265', '15621562', '13641364', '24532453']
    
    def check(self, n):
        idx = n[0:2] + n[5] + n[4]
        target = n[2]
        for i, p in enumerate(self.pos):
            if idx in p:
                if int(self.nums[i]) == int(target):
                    return 'Yes'
                else:
                    return 'No'

d1 = input().replace(' ', '').strip()
d2 = input().replace(' ', '').strip()
print(Dice(d1).check(d2))

Submission status: Wrong Answer

Solution code:

class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def set_top(self, face):
		if self.t == face:
			return
		elif self.s == face:
			self.roll('N')
		elif self.e == face:
			self.roll('W')
		elif self.w == face:
			self.roll('E')
		elif self.n == face:
			self.roll('S')
		else:
			self.roll('N')
			self.roll('N')
			
	def get_right_face(self, f):
		if self.s == f:
			return self.e
		elif self.e == f:
			return self.n
		elif self.w == f:
			return self.s
		else:
			return self.w
			
	def is_identical(self, other):
		
		f = self.faces
		for i in range(len(f)):
			self.set_top(f[i])
			other.set_top(f[i])
			if self.b != other.b:
				return False
			r1 = self.get_right_face(self.s)
			r2 = other.get_right_face(self.s)
			if r1 != r2:
				return False
		return True

faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:

class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def set_top(self, face):
		if self.t == face:
			return
		elif self.s == face:
			self.roll('N')
		elif self.e == face:
			self.roll('W')
		elif self.w == face:
			self.roll('E')
		elif self.n == face:
			self.roll('S')
		else:
			self.roll('N')
			self.roll('N')
			
	def get_right_face(self, f):
		if self.s == f:
			return self.e
		elif self.e == f:
			return self.n
		elif self.w == f:
			return self.s
		else:
			return self.w
			
	def is_identical(self, other):
		
		if self.is_matchall(other):return True
		self.roll('S')
		if self.is_matchall(other):return True
		self.roll('N')
		self.roll('E')
		if self.is_matchall(other):return True
		self.roll('W')
		self.roll('W')
		if self.is_matchall(other):return True
		self.roll('E')
		self.roll('N')
		if self.is_matchall(other):return True
		self.roll('N')
		if self.is_matchall(other):return True	
		return False


	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:

class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def set_top(self, face):
		if self.t == face:
			return
		elif self.s == face:
			self.roll('N')
		elif self.e == face:
			self.roll('W')
		elif self.w == face:
			self.roll('E')
		elif self.n == face:
			self.roll('S')
		else:
			self.roll('N')
			self.roll('N')
			
	def get_right_face(self, f):
		if self.s == f:
			return self.e
		elif self.e == f:
			return self.n
		elif self.w == f:
			return self.s
		else:
			return self.w
			
	def is_identical(self, other):
		
		if self.is_matchall(other):return True
		self.roll('S')
		if self.is_matchall(other):return True
		self.roll('N')
		self.roll('E')
		if self.is_matchall(other):return True
		self.roll('W')
		self.roll('W')
		if self.is_matchall(other):return True
		self.roll('E')
		self.roll('N')
		if self.is_matchall(other):return True
		self.roll('N')
		if self.is_matchall(other):return True
		self.roll('S')
		self.roll('S')
		self.roll('E')
		self.roll('E')
		if self.is_matchall(other):return True
		return False


	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def set_top(self, face):
		if self.t == face:
			return
		elif self.s == face:
			self.roll('N')
		elif self.e == face:
			self.roll('W')
		elif self.w == face:
			self.roll('E')
		elif self.n == face:
			self.roll('S')
		else:
			self.roll('N')
			self.roll('N')
			
	def get_right_face(self, f):
		if self.s == f:
			return self.e
		elif self.e == f:
			return self.n
		elif self.w == f:
			return self.s
		else:
			return self.w
	
	def is_identical(self, other):
		
		directions = 'SENWSENW'
		for direction in directions:
			if self.is_matchall(other): return True
			self.roll(direction)
		return False
		
	def is_identical_(self, other):
		
		if self.is_matchall(other):return True
		self.roll('S')
		if self.is_matchall(other):return True
		self.roll('N')
		self.roll('E')
		if self.is_matchall(other):return True
		self.roll('W')
		self.roll('W')
		if self.is_matchall(other):return True
		self.roll('E')
		self.roll('N')
		if self.is_matchall(other):return True
		self.roll('N')
		if self.is_matchall(other):return True
		self.roll('S')
		self.roll('S')
		self.roll('E')
		self.roll('E')
		if self.is_matchall(other):return True
		return False


	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def rotate_right(self):
		s_ = self.s
		w_ = self.w
		n_ = self.n
		e_ = self.e
		self.s = e_
		self.w = s_
		self.n = w_
		self.e = n_
	
	def is_identical(self, other):		
		directions = 'NWWWNN'
		for direction in directions:
			for i in range(4):
				if self.is_matchall(other): return True
				self.rotate_right()
			print(self.t)
			self.roll(direction)
		return False

	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
	
	def __init__(self, faces):
		self.faces = faces
		self.t = faces[0]
		self.s = faces[1]
		self.e = faces[2]
		self.w = faces[3]
		self.n = faces[4]
		self.b = faces[5]

	def roll(self, drct):
		t_ = self.t
		s_ = self.s
		e_ = self.e
		w_ = self.w
		n_ = self.n
		b_ = self.b
		if drct == 'S':
			self.t = n_
			self.s = t_
			self.n = b_
			self.b = s_
		elif drct == 'N':
			self.t = s_
			self.s = b_
			self.n = t_
			self.b = n_
		elif drct == 'E':
			self.t = w_
			self.e = t_
			self.w = b_
			self.b = e_
		elif drct == 'W':
			self.t = e_
			self.e = b_
			self.w = t_
			self.b = w_
		else:
			return
	
	def rotate_right(self):
		s_ = self.s
		w_ = self.w
		n_ = self.n
		e_ = self.e
		self.s = e_
		self.w = s_
		self.n = w_
		self.e = n_
	
	def is_identical(self, other):		
		directions = 'WEEWWE'
		for direction in directions:
			for i in range(3):
				if self.is_matchall(other): return True
				self.rotate_right()
#			print(str(self.t) + str(self.s) + str(self.w) + str(self.n) + str(self.e))
			self.roll(direction)
		return False

	def is_matchall(self, other):
		if self.t != other.t: return False
		if self.s != other.s: return False
		if self.e != other.e: return False
		if self.w != other.w: return False
		if self.n != other.n: return False
		if self.b != other.b: return False
		return True
		
faces1 = list(map(int, input().split()))
faces2 = list(map(int, input().split()))
dice1 = Dice(faces1)
dice2 = Dice(faces2)

if dice1.is_identical(dice2):
	print('Yes')
else:
	print('No')