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:
dice1_ = [int(i) for i in input().split()]
dice1 = {
	(0,0,0):100000,
    (0,0,1):dice1_[0],
    (0,-1,0):dice1_[1],
    (1,0,0):dice1_[2],
    (-1,0,0):dice1_[3],
    (0,1,0):dice1_[4],
    (0,0,-1):dice1_[5]
}
rdice1 = {
    dice1_[0]:(0,0,1),
    dice1_[1]:(0,-1,0),
    dice1_[2]:(1,0,0),
    dice1_[3]:(-1,0,0),
    dice1_[4]:(0,1,0),
    dice1_[5]:(0,0,-1)
}

dice2_ = [int(i) for i in input().split()]
dice2 = {
	(0,0,0):100000,
    (0,0,1):dice2_[0],
    (0,-1,0):dice2_[1],
    (1,0,0):dice2_[2],
    (-1,0,0):dice2_[3],
    (0,1,0):dice2_[4],
    (0,0,-1):dice2_[5]
}
rdice2 = {
    dice2_[0]:(0,0,1),
    dice2_[1]:(0,-1,0),
    dice2_[2]:(1,0,0),
    dice2_[3]:(-1,0,0),
    dice2_[4]:(0,1,0),
    dice2_[5]:(0,0,-1)
}

c = [[dice1_[0],i] for i in dice1_[1:]] + [[dice1_[1],i] for i in dice1_[2:]] + [[dice1_[2],i] for i in dice1_[3:]] + [[dice1_[3],i] for i in dice1_[4:]] +[[dice1_[4],i] for i in dice1_[5:]] + [[dice1_[5],i] for i in dice1_[6:]]
def cross(a,b):
	return(a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])
istrue = sum([1 - int(i) for i in [dice1[cross(rdice1[a],rdice1[b])] == dice2[cross(rdice2[a],rdice2[b])] for a,b in c]])
if istrue == 0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
id1 = list(map(int, input().split()))
id2 = list(map(int, input().split()))


class die:
    face = [0, 0, 0, 0, 0, 0]

    def __init__(self, nums):
        self.face = [nums[f] for f in [0, 3, 1, 2, 4, 5]]

    def roll(self, dirs):

        for di in dirs:
            c_face = list(self.face)
            if di == 'S':
                self.face = [c_face[f] for f in [4, 1, 0, 3, 5, 2]]
            elif di == 'N':
                self.face = [c_face[f] for f in [2, 1, 5, 3, 0, 4]]
            elif di == 'W':
                self.face = [c_face[f] for f in [3, 0, 2, 5, 4, 1]]
            elif di == 'E':
                self.face = [c_face[f] for f in [1, 5, 2, 0, 4, 3]]
            # print(di, self.face)

        return list(self.face)


def four_roll(d, d2):
    for r in 'SSSS':
        d.roll(r)
        if d.face == d2.face:
            print('Yes')
            return True


d2 = die(id2)
for md in (' ', 'W', 'E', 'NW', 'NE', 'WW'):
    d1 = die(id1)
    d1.roll(md)
    if four_roll(d1, d2):
        break
else:
    print('No')

Submission status: Accepted

Solution code:
import math


class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def roll_east(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp

    def roll_north(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp

    def roll_south(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp

    def roll_west(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

    def spin_left(self):
        tmp = self.north
        self.north = self.east
        self.east = self.south
        self.south = self.west
        self.west = tmp

    def check(self, dice2):
        ans = False
        for x in range(4):
            if dice2.south == self.south:
                if dice2.east == self.east and dice2.west == self.west and \
                        dice2.north == self.north and dice2.bottom == self.bottom:
                    ans = True
            self.spin_left()
        return ans

    def top_check(self, dice2):
        ans = False
        if dice2.top == self.top:
            ans |= self.check(dice2)
        if dice2.top == self.south:
            self.roll_north()
            ans |= self.check(dice2)
        if dice2.top == self.east:
            self.roll_west()
            ans |= self.check(dice2)
        if dice2.top == self.west:
            self.roll_east()
            ans |= self.check(dice2)
        if dice2.top == self.north:
            self.roll_south()
            ans |= self.check(dice2)
        if dice2.top == self.bottom:
            self.roll_south()
            self.roll_south()
            ans |= self.check(dice2)
        if ans:
            print("Yes")
        else:
            print("No")


a, b, c, d, e, f = map(int, input().split())
dice = Dice(a, b, c, d, e, f)
a, b, c, d, e, f = map(int, input().split())
dice2 = Dice(a, b, c, d, e, f)
dice.top_check(dice2)

Submission status: Accepted

Solution code:
class DICE:
    def __init__(self, li = [1,2,3,4,5,6]):
        self.vals = li
        self.nextkeys = [1, 4, 3, 2] # 2 5 4 3 nsew
        self.nowkey = 0
        self.c_key = 5
        self.nowval = li[0]
        self.distvals = []
        tmp = self.nextkeys + [self.nowkey,self.c_key]
        for t in tmp:
            self.distvals.append(self.vals[t]) 
    def operate(self, s):
        pastkey = self.nowkey
        if s == 'N':
            self.nowkey = self.nextkeys[0]
            self.nextkeys[0] = self.c_key
            self.nextkeys[1] = pastkey
        elif s == 'S':
            self.nowkey = self.nextkeys[1]
            self.nextkeys[1] = self.c_key
            self.nextkeys[0] = pastkey
        elif s == 'E':
            self.nowkey = self.nextkeys[2]
            self.nextkeys[2] = self.c_key
            self.nextkeys[3] = pastkey
        elif s == 'W':
            self.nowkey = self.nextkeys[3]
            self.nextkeys[3] = self.c_key
            self.nextkeys[2] = pastkey
        self.nowval = self.vals[self.nowkey]
        self.c_key = abs(5 - self.nowkey)
        self.distvals = []
        tmp = self.nextkeys + [self.nowkey,self.c_key]
        for t in tmp:
            self.distvals.append(self.vals[t]) 

a = list(map(int, input().split()))
b = list(map(int, input().split()))
diceA = DICE(li = a)
diceB = DICE(li = b)
s = 'NNNNWNNNNWNNNNWNNNN'+'NEEEENEEEENEEEENEEEE'+'ENWWWWNWWWWNWWWWNWWWWW'
flag = False
for i in s:
    diceA.operate(i)
    if diceA.distvals == diceB.distvals:
        print('Yes')
        flag = True
        break
if flag == False:
    print('No')

Submission status: Accepted

Solution code:
class Dice:
        def __init__(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def reset(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def rollE(self):
                temp = self.label[3]
                self.label[3] = self.label[5]
                self.label[5] = self.label[2]
                self.label[2] = self.label[0]
                self.label[0] = temp
        def rollN(self):
                temp = self.label[0]
                self.label[0] = self.label[1]
                self.label[1] = self.label[5]
                self.label[5] = self.label[4]
                self.label[4] = temp
        def rollA(self):
                temp = self.label[3]
                self.label[3] = self.label[4]
                self.label[4] = self.label[2]
                self.label[2] = self.label[1]
                self.label[1] = temp
        def printDice(self):
                print(self.label)

def check(d1, d2):
        for i in range(6):
                if d1.label[i] != d2.label[i]:
                        return False
        return True

strDice = input()
diceList = strDice.split()
dice1 = Dice(diceList)

strDice = input()
diceList = strDice.split()
dice2 = Dice(diceList)
isEqual = False

for j in range(6):
        for k in range(4):
                dice1.rollA()
                if check(dice1, dice2):
                        isEqual = True
        if j % 2 == 0:
                dice1.rollE()
        else:
                dice1.rollN()

if isEqual:
        print('Yes')
else:
        print('No')

Submission status: Accepted

Solution code:
dice1 = input().split()
dice2 = input().split()

# 上面を合わせる
d1 = {dice2[0]: "123456", dice2[1]: "263415", dice2[2]: "326154", dice2[3]: "421653", dice2[4]: "513462",
      dice2[5]: "653421"}
dice2 = [dice2[int(i) - 1] for i in d1[dice1[0]]]
# 側面を合わせる
d2 = {dice2[1]: "123456", dice2[2]: "135246", dice2[3]: "142536", dice2[4]: "154326"}
dice2 = [dice2[int(i) - 1] for i in d2[dice1[1]]]
# 裏表でセットにする
dice1 = sorted([[dice1[0], dice1[3]], [dice1[1], dice1[4]], [dice1[2], dice1[5]]])
dice2 = sorted([[dice2[0], dice2[3]], [dice2[1], dice2[4]], [dice2[2], dice2[5]]])
if dice1 == dice2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def rotateDice(direction: str, dice: list) -> list:
    s = {'N': "152304", 'W': "215043", 'E': "310542", 'S': "402351", 'R': "031425", 'L': "024135"}
    dice = [dice[int(i)] for i in s[direction]]
    return dice


dice1 = input().split()
dice2 = input().split()
all_dice_list = []
for i in range(4):
    dice1 = rotateDice('E', dice1)
    for j in range(4):
        dice1 = rotateDice('N', dice1)
        for k in range(4):
            dice1 = rotateDice('R', dice1)
            all_dice_list.append(dice1)

counter = 0
for _list in all_dice_list:
    if _list == dice2:
        print('Yes')
        counter += 1
        break

if counter == 0:
    print('No')

Submission status: Accepted

Solution code:
f = list(map(int, input().split()))
a = list(map(int, input().split()))
b = 0
for i in range(4):
	t = a[0]
	a[0] = a[2]
	a[2] = a[5]
	a[5] = a[3]
	a[3] = t
	for j in range(4):
		t = a[1]
		a[1] = a[2]
		a[2] = a[4]
		a[4] = a[3]
		a[3] = t
		if a == f:
			b = 1
for i in range(4):
	t = a[0]
	a[0] = a[1]
	a[1] = a[5]
	a[5] = a[4]
	a[4] = t
	for j in range(4):
		t = a[1]
		a[1] = a[2]
		a[2] = a[4]
		a[4] = a[3]
		a[3] = t
		if a == f:
			b = 1
if b:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
D = [[1, 3, 4, 2], [5, 3, 0, 2], [5, 1, 0, 4], [5, 4, 0, 1], [2, 0, 3, 5], [1, 2, 4, 3]]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
count = 0
for i, j in enumerate(a):
    if a.count(j) > 1:
        count += 1
        continue
    A = [a[k] for k in D[i]]
    B = [b[k] for k in D[b.index(j)]]
    if A != B:
        B = B[B.index(A[0]):] + B[:B.index(A[0])]
    if A == B:
        count += 1
if count == 6:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice(object):
    def __init__(self, faces):
        self.top = faces[0]
        self.front = faces[1]
        self.right = faces[2]
        self.left = faces[3]
        self.back = faces[4]
        self.bottom = faces[5]

    def rotate(self, command):
        pre_top = self.top
        if command == "N":
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.back
            self.back = pre_top
        elif command == "E":
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = pre_top
        elif command == "W":
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left = pre_top
        elif command == "S":
            self.top = self.back
            self.back = self.bottom
            self.bottom = self.front
            self.front = pre_top
        elif command == "R":
            pre_front = self.front
            self.front = self.left
            self.left = self.back
            self.back = self.right
            self.right = pre_front


def main() -> None:
    dice_x = Dice(list(map(int, input().split())))
    dice_y = Dice(list(map(int, input().split())))

    for i in range(4):
        dice_x.rotate("N")
        for j in range(4):
            dice_x.rotate("E")
            for k in range(4):
                dice_x.rotate("R")

                if dice_x.top != dice_y.top:
                    pass
                elif dice_x.bottom != dice_y.bottom:
                    pass
                elif dice_x.left != dice_y.left:
                    pass
                elif dice_x.right != dice_y.right:
                    pass
                elif dice_x.front != dice_y.front:
                    pass
                elif dice_x.back != dice_y.back:
                    pass
                else:
                    print("Yes")
                    return

    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# Dice III
# 2018/11/17, 2019/1/16
from collections import Counter
 
class Dice:
    def __init__(self, *num):
        if len(num) != 6:
            raise ValueError("6!")
        self.numbers = num
 
    def east(self):
        index = (3, 1, 0, 5, 4, 2)
        self.numbers = tuple((self.numbers[i] for i in index))
 
    def west(self):
        index = (2, 1, 5, 0, 4, 3)
        self.numbers = tuple((self.numbers[i] for i in index))
 
    def south(self):
        index = (4, 0, 2, 3, 5, 1)
        self.numbers = tuple((self.numbers[i] for i in index))
 
    def north(self):
        index = (1, 5, 2, 3, 0, 4)
        self.numbers = tuple((self.numbers[i] for i in index))
 
    def rot_top(self):
        """topを変えないように時計周りにくるくる回す"""
        index = (0, 2, 4, 1, 3, 5)
        self.numbers = tuple((self.numbers[i] for i in index))
 
    @property
    def top(self):
        return self.numbers[0]
 
    @property
    def front(self):
        return self.numbers[1]
 
    @property
    def right(self):
        return self.numbers[2]
 
    def __repr__(self):
        return "Dice(" + ", ".join([str(i) for i in self.numbers]) + ")"
 
 
    def align_top_and_front(self, tmp_dice):
        # topを一番レアいやつにする
        rarest = Counter(self.numbers).most_common()[-1][0]
        for i in range(4):
            if self.top == rarest:
                break
            self.east()
        for i in range(4):
            if self.top == rarest:
                break
            self.north()
 
        # topが合うまで回す
        for i in range(4):
            if self.top == tmp_dice.top:
                break
            tmp_dice.east()
 
        for i in range(4):
            if self.top == tmp_dice.top:
                break
            tmp_dice.north()
 
        # frontを合わせる
        for i in range(4):
            if self.front == tmp_dice.front:
                break
            tmp_dice.rot_top()
        return tmp_dice
 
 
    def align(self, other_dice):
        tmp = Dice(*other_dice.numbers)
        tmp = self.align_top_and_front(tmp)
        #print(self.numbers)
        #print(tmp.numbers)
        if self.numbers == tmp.numbers:
            print("Yes")
        else:
            print("No")
 
 
def main():
    num = [int(i) for i in input().split()]
    dice = Dice(*num)
 
    num = [int(i) for i in input().split()]
    other_dice = Dice(*num)
 
    Dice.align(dice, other_dice)
 
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, array):
        self.top = array[0]
        self.south = array[1]
        self.east = array[2]
        self.west = array[3]
        self.north = array[4]
        self.bottom = array[5]

    def roll_n(self):
        self.top, self.south, self.north, self.bottom = self.south, self.bottom, self.top, self.north

    def roll_s(self):
        self.top, self.south, self.north, self.bottom = self.north, self.top, self.bottom, self.south

    def roll_e(self):
        self.top, self.east, self.west, self.bottom = self.west, self.top, self.bottom, self.east

    def roll_w(self):
        self.top, self.east, self.west, self.bottom = self.east, self.bottom, self.top, self.west

    def IsEqual(self, dice2):
        if (self.top, self.south, self.east, self.west, self.north, self.bottom) == (dice2.top, dice2.south, dice2.east, dice2.west, dice2.north, dice2.bottom):
            return True
        else:
            return False


n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))

dice_1 = Dice(n1)
dice_2 = Dice(n2)

flag = False

for i in range(4):
    dice_1.roll_n()
    for j in range(4):
        dice_1.roll_e()
        if dice_1.IsEqual(dice_2):
            flag = True

dice_1.roll_e()

for i in range(4):
    dice_1.roll_n()
    for i in range(4):
        dice_1.roll_e()
        if dice_1.IsEqual(dice_2):
            flag = True



if flag:
    print('Yes')
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, face_val=None):
        self.f_keys = [self.__TOP,  # 0
                       self.__FRONT,  # 1
                       self.__RIGHT,  # 2
                       self.__LEFT,  # 3
                       self.__BACK,  # 4
                       self.__BOTTOM  # 5
                       ]

        if face_val is None or len(face_val) != 6:
            face_val = ['1', '2', '3', '4', '5', '6']

        self.f_key_to_val = {}
        self.f_val_to_key = {}
        for f_key, val in zip(self.f_keys, face_val):
            self.f_key_to_val[f_key] = val
            self.f_val_to_key[val] = f_key

    MOVE_SWAP_FACES = {
        'S': [(__BACK, __TOP), (__TOP, __FRONT), (__FRONT, __BOTTOM), (__BOTTOM, __BACK)],
        'W': [(__RIGHT, __TOP), (__TOP, __LEFT), (__LEFT, __BOTTOM), (__BOTTOM, __RIGHT)],
        'E': [(__LEFT, __TOP), (__TOP, __RIGHT), (__RIGHT, __BOTTOM), (__BOTTOM, __LEFT)],
        'N': [(__FRONT, __TOP), (__TOP, __BACK), (__BACK, __BOTTOM), (__BOTTOM, __FRONT)],
        'RCW' : [(__LEFT, __FRONT), (__FRONT, __RIGHT), (__RIGHT, __BACK), (__BACK, __LEFT)],   # rotate clockwise
        'RCCW': [(__RIGHT, __FRONT), (__FRONT, __LEFT), (__LEFT, __BACK), (__BACK, __RIGHT)],   # rotate counter clockwise
    }

    def dice_move(self, direction_list):
        for direction in direction_list:
            prev_faces = self.f_keys[:]
            for prev_f, next_f in self.MOVE_SWAP_FACES[direction]:
                self.f_keys[next_f] = prev_faces[prev_f]
            #print(self.f_keys)

    MOVE_TO_TOP = {__TOP:[], __FRONT:['N'], __RIGHT:['W'], __LEFT:['E'], __BACK:['S'], __BOTTOM:['N','N']}

    def dice_fix(self, top, front):
        if type(top) == str:
            top = self.f_val_to_key[top]
            front = self.f_val_to_key[front]

        # 上面を指定された面にする
        if top != self.f_keys[self.__TOP]:
            now_top = self.f_keys.index(top)
            move = self.MOVE_TO_TOP[now_top]
            self.dice_move(move)

        if top != self.f_keys[self.__TOP]:
            raise AssertionError # not top

        # 前面を指定された面にする
        if front != self.f_keys[self.__FRONT]:
            for i in range(3):
                self.dice_move(['RCW'])
                if front == self.f_keys[self.__FRONT]:
                    break
            else:
                return False    # 3回回転するうちに指定された面がfrontに来ないとおかしい
        return True

    def get_value(self, face):
        return self.f_key_to_val[self.f_keys[face]]

    def is_identical(self, other) -> bool:
        # 含まれるvalueが同じであることをチェック
        self_values = [self.get_value(x) for x in self.f_keys]
        other_values = [other.get_value(x) for x in other.f_keys]
        if set(self_values) != set(other_values):
            return False

        #selfのtopとfrontをotherに合わせる、失敗したらidenticalではない
        other_top = other.get_value(self.__TOP)
        other_front = other.get_value(self.__FRONT)
        ret = self.dice_fix(other_top, other_front)
        if not ret:
            return False

        #全面が同じであることをチェック、すべて通過したらTrue
        for i in range(6):
            a1 = self.get_value(i)
            a2 = other.get_value(i)

            if self.get_value(i) != other.get_value(i):
                return False

        return True


    def __repr__(self):
        return f'({",".join(map(str, self.f_keys))})'


def main():
    d1_faces = input().split()
    dice1 = Dice(d1_faces)
    d2_faces = input().split()
    dice2 = Dice(d2_faces)
    print(['No','Yes'][dice1.is_identical(dice2)])

main()

Submission status: Accepted

Solution code:
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')

Submission status: Accepted

Solution code:


class Dice:
    def __init__(self):
        self.diceNum: List[int] = [] 

    def setNum(self,i):
        self.pos = i[0]
        self.diceNum.append(i[0])
        self.diceNum.append(i[1])
        self.diceNum.append(i[2])
        self.diceNum.append(i[3])
        self.diceNum.append(i[4])
        self.diceNum.append(i[5])
    def getTopPos(self):
        return self.diceNum[0]    
    def moveToTopnum(self,n):
        i = 0
        for i in range(0,4):
            if (self.getTopPos() == n ):
                return True
            self.move("S")
        else:
            for j in range(0,4):
                if (self.getTopPos() == n ):
                    return True
                self.move("E")
        return False
    def getFrontPos(self):
        return self.diceNum[1]
    def getRightPos(self):
        return self.diceNum[2]
    def yokoRotate(self):
            i0=self.diceNum[0]
            i1=self.diceNum[2] 
            i2=self.diceNum[4] 
            i3=self.diceNum[1]
            i4=self.diceNum[3]
            i5=self.diceNum[5]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
    def move(self,d):
        if (d == "E"):
            i0=self.diceNum[3]
            i1=self.diceNum[1] 
            i2=self.diceNum[0] 
            i3=self.diceNum[5]
            i4=self.diceNum[4]
            i5=self.diceNum[2]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "W"):
            i0=self.diceNum[2]
            i1=self.diceNum[1] 
            i2=self.diceNum[5] 
            i3=self.diceNum[0]
            i4=self.diceNum[4]
            i5=self.diceNum[3]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "S"):
            i0=self.diceNum[4]
            i1=self.diceNum[0] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[5]
            i5=self.diceNum[1]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
        if (d == "N"):
            i0=self.diceNum[1]
            i1=self.diceNum[5] 
            i2=self.diceNum[2] 
            i3=self.diceNum[3]
            i4=self.diceNum[0]
            i5=self.diceNum[4]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
    def rotateToFrontnum(self,n):
        for i in range(0,4):
            self.yokoRotate()
            if ( self.getFrontPos() == n):
                return True
        return False
    def isEqual(self,d):
        for i in range(0,6):
            if (self.diceNum[i] != d.diceNum[i]):
                return False
        return True

 
l = list(map(int,input().split()))
dice = Dice()
dice.setNum(l)

min = 10000
r_num = 0
for i in set(l):
    if (min > l.count(i)):
       min = l.count(i)
       r_num = i
dice.moveToTopnum(r_num)


l2 = list(map(int,input().split()))
dice2 = Dice()
dice2.setNum(l2)

t = dice.getTopPos()
f = dice.getFrontPos()
r = dice.getRightPos()
#print ("test0:",t,f,r)
if (dice2.moveToTopnum(t) != True):
    print ("No")
#    print ("t1")
elif (dice2.rotateToFrontnum(f) != True):
    print ("No")
#    print ("t2")

elif (dice.isEqual(dice2) == False ):
    print ("No")
#    print ("t3")
else:
    print ("Yes")    
#print (dice.diceNum)
#print (dice2.diceNum)

Submission status: Accepted

Solution code:
d1=input().split()
d2=input().split()

def roll(Dice,Vector):
    if Vector == "N":
        c=Dice[0]
        Dice[0]=Dice[1]
        Dice[1]=Dice[5]
        Dice[5]=Dice[4]
        Dice[4]=c
    elif Vector == "W":
        c=Dice[0]
        Dice[0]=Dice[2]
        Dice[2]=Dice[5]
        Dice[5]=Dice[3]
        Dice[3]=c
    elif Vector == "E":
        c=Dice[0]
        Dice[0]=Dice[3]
        Dice[3]=Dice[5]
        Dice[5]=Dice[2]
        Dice[2]=c
    elif Vector == "S":
        c=Dice[0]
        Dice[0]=Dice[4]
        Dice[4]=Dice[5]
        Dice[5]=Dice[1]
        Dice[1]=c

v=list("NNNNWNNNWNNNENNNENNNWNNN")
f=0
for item in v:
    roll(d2,item)
    if d1==d2:
        print("Yes")
        f+=1
        break
if f==0:
    print("No")

Submission status: Accepted

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

slist = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")

    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]

    dice = tmp

    if dice == dice2:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
d=list(map(int,input().split()))
o=list(map(int,input().split()))
if o[0]==d[1]:
	d[0],d[1],d[4],d[5]=d[1],d[5],d[0],d[4]		
elif o[0]==d[2]:
	d[0],d[2],d[3],d[5]=d[2],d[5],d[0],d[3]
elif o[0]==d[3]:
	d[0],d[2],d[3],d[5]=d[3],d[0],d[5],d[2]	
elif o[0]==d[4]:
	d[0],d[1],d[4],d[5]=d[4],d[0],d[5],d[1]		
elif o[0]==d[5]:
	d[0],d[1],d[4],d[5]=d[5],d[4],d[1],d[0]
while o[1]!=d[1]:
	d[1],d[2],d[4],d[3]=d[3],d[1],d[2],d[4]
if d==o:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
d, d2 = [list(map(int, input().split())) for i in range(2)]  
from collections import OrderedDict
def make_p(d):
    p = OrderedDict()
    for k, v in zip(["T", "N", "S", "E", "W", "B"], [d[0], d[4], d[1], d[2], d[3], d[5]]):
        p[k] = v
    return p

p, p2 = make_p(d), make_p(d2)

for c in "SSSWNNNWNNNESSSWNNNESSSX":       
    t, n, s, e, w, b = p["T"], p["N"], p["S"], p["E"], p["W"], p["B"]
    if p == p2:
        print("Yes")
        break
    if c == "X":
        print("No")
    if c == "N":
        p["N"], p["T"], p["S"], p["B"]= t, s, b, n
    if c == "S":
        p["N"], p["T"], p["S"], p["B"]= b, n, t, s
    if c == "E":
        p["E"], p["T"], p["W"], p["B"]= t, w, b, e
    if c == "W":
        p["E"], p["T"], p["W"], p["B"]= b, e, t, w

Submission status: Accepted

Solution code:
def swap(dice,i,j,k,l):#diceの目をi→ｊ→ｋ→ｌ→iの順に入れ替える
    x=dice[l]
    dice[l]=dice[k]
    dice[k]=dice[j]
    dice[j]=dice[i]
    dice[i]=x
    return dice

def Sroll(dice):
    dice=swap(dice,0,1,5,4)
    return dice

def Eroll(dice):
    dice=swap(dice,0,2,5,3)
    return dice

def Wroll(dice):
    dice=swap(dice,0,3,5,2)
    return dice

def Nroll(dice):
    dice=swap(dice,0,4,5,1)
    return dice




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

top=dice1[0]
fro=dice1[1]

for j in range(0,8):
    if(fro==dice2[1]):
        break
    if(j==3):
        dice2=Eroll(dice2)
    dice2=Sroll(dice2)
while(top!=dice2[0]):
    dice2=Eroll(dice2)

if(dice1[2]==dice2[2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

# 0:上側 1:南 2:東 3:西 4:北 5:下側

class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.pattern = 'NNNNENNNENNNWNNNWNNNENNN'
        self.ret = 'No'
        
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]
        
        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def match(self, Std):
        for i in range(6):
            self.work[i] = self.number[i]
        
        for i in range(len(self.pattern)):
            self.roll(self.pattern[i])
            if self.number == Std:
                self.ret = 'Yes'
                break
                
    def get_ret(self):
        return self.ret

tableStd = list(map(int, input().split()))
# dice1.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

dice.match(tableStd)
print("%s"%(dice.get_ret()))