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: Accepted

Solution code:
n1 = [int(i) for i in input().split()]
n2 = [int(i) for i in input().split()]


class Dice(object):
    def __init__(self,num):
        self.n = num[4]
        self.e = num[2]
        self.w = num[3]
        self.s = num[1]
        self.center = num[0]
        self.back = num[5]

    def number(self):
        number = [self.center, self.s, self.e, self.w, self.n, self.back]
        return number

    def move(self,str):
        if str == 'N':
            x = self.n
            self.n = self.center
            self.center = self.s
            self.s = self.back
            self.back = x
            return self.center
        elif str == 'S':
            x = self.s
            self.s = self.center
            self.center = self.n
            self.n = self.back
            self.back = x
            return self.center
        elif str== 'E':
            x = self.e
            self.e = self.center
            self.center = self.w
            self.w = self.back
            self.back = x
            return self.center
        elif str == 'W':
            x = self.w
            self.w = self.center
            self.center = self.e
            self.e = self.back
            self.back = x
            return self.center

dice1 = Dice(n1)
dice2 = Dice(n2)
bool = False
status = dice1.center


for i in range(4):
    for j in range(4):
        for k in range(4):
            # print(dice1.number(), dice2.number())
            if dice1.number() == dice2.number():
                bool = True
            else:
                dice1.move('N')
                dice1.move('E')
                dice1.move('S')
        dice1.move('E')
    dice1.move('N')




print('Yes') if bool == True else print('No')

Submission status: Accepted

Solution code:
class Dice:

    __top = 0
    __front = 1
    __right = 2
    __left = 3
    __back = 4
    __bottom = 5

    def __init__(self, a, b, c, d, e, f):
        self.__dice = [a,b,c,d,e,f]

    def S(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top]    = dice_before[Dice.__back]
        self.__dice[Dice.__front]  = dice_before[Dice.__top]
        self.__dice[Dice.__right]  = dice_before[Dice.__right]
        self.__dice[Dice.__left]   = dice_before[Dice.__left]
        self.__dice[Dice.__back]   = dice_before[Dice.__bottom]
        self.__dice[Dice.__bottom] = dice_before[Dice.__front]

    def E(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top]    = dice_before[Dice.__left]
        self.__dice[Dice.__front]  = dice_before[Dice.__front]
        self.__dice[Dice.__right]  = dice_before[Dice.__top]
        self.__dice[Dice.__left]   = dice_before[Dice.__bottom]
        self.__dice[Dice.__back]   = dice_before[Dice.__back]
        self.__dice[Dice.__bottom] = dice_before[Dice.__right]

    def W(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top]    = dice_before[Dice.__right]
        self.__dice[Dice.__front]  = dice_before[Dice.__front]
        self.__dice[Dice.__right]  = dice_before[Dice.__bottom]
        self.__dice[Dice.__left]   = dice_before[Dice.__top]
        self.__dice[Dice.__back]   = dice_before[Dice.__back]
        self.__dice[Dice.__bottom] = dice_before[Dice.__left]

    def N(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top]    = dice_before[Dice.__front]
        self.__dice[Dice.__front]  = dice_before[Dice.__bottom]
        self.__dice[Dice.__right]  = dice_before[Dice.__right]
        self.__dice[Dice.__left]   = dice_before[Dice.__left]
        self.__dice[Dice.__back]   = dice_before[Dice.__top]
        self.__dice[Dice.__bottom] = dice_before[Dice.__back]

    def turn(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top]    = dice_before[Dice.__top]
        self.__dice[Dice.__front]  = dice_before[Dice.__right]
        self.__dice[Dice.__right]  = dice_before[Dice.__back]
        self.__dice[Dice.__left]   = dice_before[Dice.__front]
        self.__dice[Dice.__back]   = dice_before[Dice.__left]
        self.__dice[Dice.__bottom] = dice_before[Dice.__bottom]

    def top(self):
        return(self.__dice[Dice.__top])

    def front(self):
        return(self.__dice[Dice.__front])

    def right(self):
        return(self.__dice[Dice.__right])

    def left(self):
        return(self.__dice[Dice.__left])

    def back(self):
        return(self.__dice[Dice.__back])

    def bottom(self):
        return(self.__dice[Dice.__bottom])

    def compare(self, dice):
        if (self.__dice[Dice.__top]    == dice.__dice[Dice.__top] and
            self.__dice[Dice.__front]  == dice.__dice[Dice.__front] and
            self.__dice[Dice.__right]  == dice.__dice[Dice.__right] and
            self.__dice[Dice.__left]   == dice.__dice[Dice.__left] and
            self.__dice[Dice.__back]   == dice.__dice[Dice.__back] and
            self.__dice[Dice.__bottom] == dice.__dice[Dice.__bottom]):
            print("Yes")
        else:
            print("No")

    def print(self):
        print('[top   ] :', self.__dice[Dice.__top])
        print('[front ] :', self.__dice[Dice.__front])
        print('[right ] :', self.__dice[Dice.__right])
        print('[left  ] :', self.__dice[Dice.__left])
        print('[back  ] :', self.__dice[Dice.__back])
        print('[bottom] :', self.__dice[Dice.__bottom])


def S(dice, top):
    for t in range(4):
        if dice.top() == top:
            return dice
        dice.S()
    return dice

def turn(dice, front):
    for t in range(4):
        if dice.front() == front:
            return dice
        dice.turn()
    return dice

a, b, c, d, e, f = input().split()
dice1 = Dice(a, b, c, d, e, f)

top = max(a,b,c,d,e,f)
dice1 = S(dice1, top)
a,b,c,d,e,f = input().split()
dice2 = Dice(a,b,c,d,e,f)

top = dice1.top()
front = dice1.front()

for to in range(2):
    dice2 = S(dice2, top)
    if dice2.top() == top:
        break
    else:
        dice2.turn()

for fr in range(4):
    dice2 = turn(dice2, front)
    if dice2.front() == front:
        break

dice1.compare(dice2)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,l1,l2,l3,l4,l5,l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.top = 1
        self.front = 2
        self.right = 3

    def get_top(self):
        return eval("self." + 'l' + str(self.top))

    def get_right(self):
        return eval("self." + 'l' + str(self.right))

    def get_front(self):
        return eval("self." + 'l' + str(self.front))

    def get_bottom(self):
        return eval("self." + 'l' + str(7-self.top))

    def get_left(self):
        return eval("self." + 'l' + str(7-self.right))

    def get_back(self):
        return eval("self." + 'l' + str(7-self.front))

    def rot(self):
        self.front,self.right = self.right,7-self.front

    def move(self, order):
        if order == 'S':
            pretop = self.top
            self.top = 7 - self.front
            self.front = pretop
        elif order == 'E':
            pretop = self.top
            self.top = 7 - self.right
            self.right = pretop


def match_top(dice,target):
    for i in range(4):
        dice.move('S')
        if dice.get_top() == target:
            return dice
    return False


l = list(map(int,input().split()))
d1 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

l = list(map(int,input().split()))
d2 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

d1_top = d1.get_top()
d1_front = d1.get_front()
d1_right = d1.get_right()
d1_bottom = d1.get_bottom()
d1_back = d1.get_back()
d1_left = d1.get_left()
ret = match_top(d2,d1_top)

if ret == False:
    d2.move('E')
    ret = match_top(d2,d1_top)
if ret == False:
    print('No')
else:
    matched = False
    for i in range(4):
        d2.rot()
        if d2.get_front() == d1_front and \
        d2.get_right() == d1_right and \
        d2.get_bottom() == d1_bottom and \
        d2.get_left() == d1_left and \
        d2.get_back() == d1_back:
            matched = True
            print ('Yes')
            break
    if not matched:
        print('No')

Submission status: Accepted

Solution code:
def move(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d
     
dice_1 = tuple(map(str,input().split()))
dice_2 = tuple(map(str,input().split()))

def gen_all(dice_1):
    dice = {dice_1}
    while True:
        dice2 = {move(d,r) for d in dice for r in list("NEWS")}.union(dice)
        if dice == dice2: break
        dice = dice2
    return dice    

print("Yes" if dice_2 in gen_all(dice_1) else "No")

Submission status: Accepted

Solution code:
dice = tuple(map(int,input().split()))

def rot(dice,rotation):
    if rotation == "E":
        dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])
    elif rotation == "W":
        dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])
    elif rotation == "N":
        dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])
    elif rotation == "S":
        dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])
    return dice

def make_all_pattern(dice):
    pattern = {dice}
    pattern2 = pattern
    while True:
        pattern2 = pattern.union({rot(d,r) for d in pattern for r in list("NEWS")})
        if pattern2 == pattern:
            break
        pattern = pattern2
    return pattern

dice2 = tuple(map(int,input().split()))

if dice2 in make_all_pattern(dice):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()

        print(die.pips[2])


def main():
    die1 = init_die()
    die2 = init_die()

    if sorted(die1.pips) != sorted(die2.pips):
        print('No')
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    print('Yes')
                    sys.exit(0)
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die('N')
            if idx in {3}:
                die1.move_die('N')
                die1.move_die('E')
            if idx in {4}:
                die1.move_die('E')
                die1.move_die('E')

        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()

        print(die.pips[2])


def are_identical(die1, die2):
    if sorted(die1.pips) != sorted(die2.pips):
        return 'No'
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    return 'Yes'
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die('N')
            if idx in {3}:
                die1.move_die('N')
                die1.move_die('E')
            if idx in {4}:
                die1.move_die('E')
                die1.move_die('E')

        return 'No'


def main():
    die1 = init_die()
    die2 = init_die()
    print(are_identical(die1, die2))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
class Dice():
	def __init__(self, label):
		self.d = label
		
	def __eq__(self, other):
		return (self.d[1] == other.d[1] and self.d[2] == other.d[2] and self.d[3] == other.d[3] and self.d[4] == other.d[4] and self.d[5] == other.d[5] and self.d[6] == other.d[6])
	
	def __ne__(self, other):
		return (self.d[1] != other.d[1] or self.d[2] != other.d[2] or self.d[3] != other.d[3] or self.d[4] != other.d[4] or self.d[5] != other.d[5] or self.d[6] != other.d[6])
	
	def roll(self, drt):
		if drt == 'N':
			self.d[1], self.d[2], self.d[6], self.d[5] = self.d[2], self.d[6], self.d[5], self.d[1]
		elif drt == 'E':
			self.d[1], self.d[3], self.d[6], self.d[4] = self.d[4], self.d[1], self.d[3], self.d[6]
		elif drt == 'S':
			self.d[2], self.d[6], self.d[5], self.d[1] = self.d[1], self.d[2], self.d[6], self.d[5]
		elif drt == 'W':
			self.d[4], self.d[1], self.d[3], self.d[6] = self.d[1], self.d[3], self.d[6], self.d[4]
		elif drt == 'r':
			self.d[2], self.d[3], self.d[5], self.d[4] = self.d[4], self.d[2], self.d[3], self.d[5]
		elif drt == 'l':
			self.d[4], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[3], self.d[5], self.d[4]
	
	def printl(self, lct):
		print(self.d[lct])
		
label = [0]	
label.extend(list(map(int, input().split())))
dice1 = Dice(label)

label2 = [0]
label2.extend(list(map(int, input().split())))
dice2 = Dice(label2)

S1 = 'NNNNENNNNENNNNENNNNrNNNNllNNNN'
leng = len(S1)

for j in range(leng):
		if dice1 == dice2:
			print("Yes")
			break
		dice2.roll(S1[j])

if dice1 != dice2:
	print("No")

Submission status: Accepted

Solution code:
A,B,C,D,E,F = map(int, input().split())
u,v,w,x,y,z = map(int, input().split())
s = 0
for _ in range(3):
    for _ in range(4):
        if A == u and B == v and C == w and D == x and E == y and F == z:
            s = 1
            break
        A,B,C,D,E,F = A,C,E,B,D,F #R
    A,B,C,D,E,F = D,B,A,F,E,C #E
    for _ in range(4):
        if A == u and B == v and C == w and D == x and E == y and F == z:
            s = 1
            break
        A,B,C,D,E,F = A,C,E,B,D,F #R
    A,B,C,D,E,F = B,F,C,D,A,E #N

if s == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
class Dice:
    """Dice class"""
    def __init__(self):                  # ?????????????????????
        self.eyeIndex = 1        #center
        self.eyeIndex_E = 3      #east
        self.eyeIndex_W = 4      #west
        self.eyeIndex_N = 5      #north
        self.eyeIndex_S = 2      #south
        self.eye = 0
        self.eye_S = 0
        self.eye_E = 0
        self.eye_W = 0
        self.eye_N = 0
        self.eye_B = 0
        self.eyes = []

    def convEyesIndexToEyes(self):
        self.eye = self.eyes[self.eyeIndex]
        self.eye_S = self.eyes[self.eyeIndex_S]
        self.eye_E = self.eyes[self.eyeIndex_E]
        self.eye_N = self.eyes[self.eyeIndex_N]
        self.eye_W = self.eyes[self.eyeIndex_W]
        self.eye_B = self.eyes[7-self.eyeIndex]

    def shakeDice(self, in_command):
        pre_eyeIndex = self.eyeIndex
        if in_command == "E":
            self.eyeIndex = self.eyeIndex_W 
            self.eyeIndex_E = pre_eyeIndex 
            self.eyeIndex_W = 7 - self.eyeIndex_E
            
        elif in_command == "W":
            self.eyeIndex = self.eyeIndex_E 
            self.eyeIndex_W = pre_eyeIndex
            self.eyeIndex_E = 7 - self.eyeIndex_W
            
        elif in_command == "N":
            self.eyeIndex = self.eyeIndex_S 
            self.eyeIndex_N = pre_eyeIndex 
            self.eyeIndex_S = 7 - self.eyeIndex_N

        elif in_command == "S":
            self.eyeIndex = self.eyeIndex_N         
            self.eyeIndex_S = pre_eyeIndex 
            self.eyeIndex_N = 7 - self.eyeIndex_S 
        
        self.convEyesIndexToEyes()


    def rotateDice(self):
        #rotate clockwise
        pre_E = self.eyeIndex_E
        pre_S = self.eyeIndex_S
        pre_W = self.eyeIndex_W
        pre_N = self.eyeIndex_N
        
        self.eyeIndex_E = pre_N
        self.eyeIndex_S = pre_E
        self.eyeIndex_W = pre_S
        self.eyeIndex_N = pre_W

        self.convEyesIndexToEyes()
        
    def getEye(self):
        return self.eye
        
    def getEye_S(self):
        return self.eye_S
    
    def getEye_E(self):
        return self.eye_E

    def getEye_N(self):
        return self.eye_N

    def getEye_W(self):
        return self.eye_W

    def getEye_B(self):
        return self.eye_B
        
    def setEyes(self, eyes):             # setEyes()???????????? ???????????????
        eyes = "0 " + eyes
        self.eyes = list(map(int, eyes.split(" ")))
        self.convEyesIndexToEyes()
        
dice_1 = Dice()
dice_1.setEyes(input().rstrip())

dice_2 = Dice()
dice_2.setEyes(input().rstrip())


shake_direction = "E"
judge = "def"

shake_cnt = 0

while True:
    if dice_2.getEye() == dice_1.getEye() and dice_2.getEye_B() == dice_1.getEye_B():
        break

    dice_2.shakeDice(shake_direction)
    shake_cnt = shake_cnt + 1
    
    if shake_cnt >= 8:
        judge = "No"
        break
    if shake_cnt >= 4:
        shake_direction = "N"

rotate_cnt = 0
if judge != "No":
    while True:
        if dice_1.getEye() == dice_2.getEye() and dice_1.getEye_E() == dice_2.getEye_E() and \
            dice_1.getEye_S() == dice_2.getEye_S() and dice_1.getEye_W() == dice_2.getEye_W() and \
            dice_1.getEye_N() == dice_2.getEye_N():
            break
        
        dice_2.rotateDice()
        rotate_cnt = rotate_cnt + 1
        
        if rotate_cnt >= 5:
            judge = "No"
            break


if judge != "No":
    dice_1.shakeDice(shake_direction)
    dice_1.shakeDice(shake_direction)

    dice_2.shakeDice(shake_direction)
    dice_2.shakeDice(shake_direction)


    if dice_1.getEye() == dice_2.getEye():
        judge = "Yes"
    else:
        judge = "No"
        

print(judge)

Submission status: Accepted

Solution code:
class Dice:
    """Dice class"""
    def __init__(self):                  # ?????????????????????
        self.eyeIndex = 1        #center
        self.eyeIndex_E = 3      #east
        self.eyeIndex_W = 4      #west
        self.eyeIndex_N = 5      #north
        self.eyeIndex_S = 2      #south
        self.eye = 0
        self.eye_S = 0
        self.eye_E = 0
        self.eye_W = 0
        self.eye_N = 0
        self.eye_B = 0
        self.eyes = []

    def convEyesIndexToEyes(self):
        self.eye = self.eyes[self.eyeIndex]
        self.eye_S = self.eyes[self.eyeIndex_S]
        self.eye_E = self.eyes[self.eyeIndex_E]
        self.eye_N = self.eyes[self.eyeIndex_N]
        self.eye_W = self.eyes[self.eyeIndex_W]
        self.eye_B = self.eyes[7-self.eyeIndex]

    def shakeDice(self, in_command):
        pre_eyeIndex = self.eyeIndex
        if in_command == "E":
            self.eyeIndex = self.eyeIndex_W 
            self.eyeIndex_E = pre_eyeIndex 
            self.eyeIndex_W = 7 - self.eyeIndex_E
            
        elif in_command == "W":
            self.eyeIndex = self.eyeIndex_E 
            self.eyeIndex_W = pre_eyeIndex
            self.eyeIndex_E = 7 - self.eyeIndex_W
            
        elif in_command == "N":
            self.eyeIndex = self.eyeIndex_S 
            self.eyeIndex_N = pre_eyeIndex 
            self.eyeIndex_S = 7 - self.eyeIndex_N

        elif in_command == "S":
            self.eyeIndex = self.eyeIndex_N         
            self.eyeIndex_S = pre_eyeIndex 
            self.eyeIndex_N = 7 - self.eyeIndex_S 
        
        self.convEyesIndexToEyes()


    def rotateDice(self):
        #rotate clockwise
        pre_E = self.eyeIndex_E
        pre_S = self.eyeIndex_S
        pre_W = self.eyeIndex_W
        pre_N = self.eyeIndex_N
        
        self.eyeIndex_E = pre_N
        self.eyeIndex_S = pre_E
        self.eyeIndex_W = pre_S
        self.eyeIndex_N = pre_W

        self.convEyesIndexToEyes()
        
    def getEye(self):
        return self.eye
        
    def getEye_S(self):
        return self.eye_S
    
    def getEye_E(self):
        return self.eye_E

    def getEye_N(self):
        return self.eye_N

    def getEye_W(self):
        return self.eye_W

    def getEye_B(self):
        return self.eye_B
        
    def setEyes(self, eyes):             # setEyes()???????????? ???????????????
        eyes = "0 " + eyes
        self.eyes = list(map(int, eyes.split(" ")))
        self.convEyesIndexToEyes()
        
dice_1 = Dice()
dice_1.setEyes(input().rstrip())

dice_2 = Dice()
dice_2.setEyes(input().rstrip())


shake_direction = "E"
judge = "def"

shake_cnt = 0

while True:
    if dice_2.getEye() == dice_1.getEye() and dice_2.getEye_B() == dice_1.getEye_B():
        break

    dice_2.shakeDice(shake_direction)
    shake_cnt = shake_cnt + 1
    
    if shake_cnt >= 8:
        judge = "No"
        break
    if shake_cnt >= 4:
        shake_direction = "N"

rotate_cnt = 0
if judge != "No":
    while True:
        if dice_1.getEye() == dice_2.getEye() and dice_1.getEye_E() == dice_2.getEye_E() and \
            dice_1.getEye_S() == dice_2.getEye_S() and dice_1.getEye_W() == dice_2.getEye_W() and \
            dice_1.getEye_N() == dice_2.getEye_N():
            judge = "Yes"
            break
        
        dice_2.rotateDice()
        rotate_cnt = rotate_cnt + 1
        
        if rotate_cnt >= 5:
            judge = "No"
            break


print(judge)

Submission status: Accepted

Solution code:
class dice:
    def __init__(self, pip):
        self.pip = pip
        
    def move(self,dir):
        if str(dir) == "E":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]
        elif str(dir) == "W":
            self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]
        elif str(dir) == "N":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]
        elif str(dir) == "S":
            self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]

d1 = dice(list(map(int,input().split())))
d2 = dice(list(map(int,input().split())))

ans = "No"
for op in "EEENEEENEEESEEESEEENEEEN":
    if d1.pip == d2.pip:
        ans = "Yes"
        break
    d2.move(op)

print(ans)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self):
        self.faces=[]

    def rotate(self, direction):
        tmp = self.faces.copy()

        if direction =="N":
            self.faces[5-1] = tmp[1-1]
            self.faces[1-1] = tmp[2-1]
            self.faces[2-1] = tmp[6-1]
            self.faces[6-1] = tmp[5-1]
        if direction =="S":
            self.faces[5-1] = tmp[6-1]
            self.faces[1-1] = tmp[5-1]
            self.faces[2-1] = tmp[1-1]
            self.faces[6-1] = tmp[2-1]
        if direction =="W":
            self.faces[4-1] = tmp[1-1]
            self.faces[1-1] = tmp[3-1]
            self.faces[3-1] = tmp[6-1]
            self.faces[6-1] = tmp[4-1]
        if direction =="E":
            self.faces[3-1] = tmp[1-1]
            self.faces[1-1] = tmp[4-1]
            self.faces[4-1] = tmp[6-1]
            self.faces[6-1] = tmp[3-1]
        return 0

    def spin(self):
        self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\
        self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1]

        return 0

d1 = Dice()
d2 = Dice()
d1.faces=[int(x) for x in input().split(" ")]
d2.faces=[int(x) for x in input().split(" ")]
up,front = d1.faces[0], d1.faces[1]

res = "No"
#set up side
for _ in range(3):
    for _ in range(4):
        for ___ in range(4):
            #print("d1: {}".format(d1.faces))
            #print("d2: {}".format(d2.faces))
            if d1.faces == d2.faces:
                res = "Yes"
                break
            d2.spin()
        d2.rotate("W")
    d2.rotate("N")

print(res)

Submission status: Accepted

Solution code:
import sys
answer = [i for i in input().split()]
inp = [i for i in input().split()]
if answer == inp:
    print("Yes")
    sys.exit()
for i in range(1,33):
    if (i<=20 and i%5==0) or i==22 or i==27 or i==28:
        s = "N"
    else:
        s = "E"
    if s == "E":
        a = []
        a.append(inp[3])
        a.append(inp[1])
        a.append(inp[0])
        a.append(inp[5])
        a.append(inp[4])
        a.append(inp[2])
        inp = a
        if answer == inp:
            print("Yes")
            break
    elif s == "N":
        a = []
        a.append(inp[1])
        a.append(inp[5])
        a.append(inp[2])
        a.append(inp[3])
        a.append(inp[0])
        a.append(inp[4])
        inp = a
        if answer == inp:
            print("Yes")
            break
    if i == 32:
        print ("No")

Submission status: Accepted

Solution code:
import random
class Dice:
    def __init__(self, usr_input):
        self.eyes = list(map(int, usr_input.split()))
        self.pos = {label:eye for label, eye in zip(range(1, 7), self.eyes)}
        #self.com = list(command)

    def roll(self,c):
        self.eyes = [n for n in self.pos.values()]
        if c == 'E':
            self.pos[1] = self.eyes[3]
            self.pos[3] = self.eyes[0]
            self.pos[4] = self.eyes[5]
            self.pos[6] = self.eyes[2]
        elif c == 'N':
            self.pos[1] = self.eyes[1]
            self.pos[2] = self.eyes[5]
            self.pos[5] = self.eyes[0]
            self.pos[6] = self.eyes[4]
        elif c == 'S':
            self.pos[1] = self.eyes[4]
            self.pos[2] = self.eyes[0]
            self.pos[5] = self.eyes[5]
            self.pos[6] = self.eyes[1]
        elif c == 'W':
            self.pos[1] = self.eyes[2]
            self.pos[3] = self.eyes[5]
            self.pos[4] = self.eyes[0]
            self.pos[6] = self.eyes[3]

if __name__ == '__main__':
    dice1 = Dice(input())
    dice2 = Dice(input())
    def is_same(obj_1, obj_2):
        for i in range(720):
            if obj_1.pos == obj_2.pos:
                return True
            c = random.choice(['N','E','W','S'])
            obj_1.roll(c)
        return False
    if is_same(dice1, dice2):
        print('Yes')
    else:
        print('No')