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:
class Dice:
    def __init__(self,dim=list(range(1,7))):
        self.dim = dim

    def roll(self,direction):
        if direction == "N":
            buff = self.dim[0]
            self.dim[0] = self.dim[1]
            self.dim[1] = self.dim[5]
            self.dim[5] = self.dim[4]
            self.dim[4] = buff

        if direction == "E":
            buff = self.dim[3]
            self.dim[3] = self.dim[5]
            self.dim[5] = self.dim[2]
            self.dim[2] = self.dim[0]
            self.dim[0] = buff

        if direction == "W":
            buff = self.dim[0]
            self.dim[0] = self.dim[2]
            self.dim[2] = self.dim[5]
            self.dim[5] = self.dim[3]
            self.dim[3] = buff

        if direction == "S":
            buff = self.dim[0]
            self.dim[0] = self.dim[4]
            self.dim[4] = self.dim[5]
            self.dim[5] = self.dim[1]
            self.dim[1] = buff

lst = list(map(int,input().split()))
D = Dice(lst)
D2_lst = list(map(int,input().split()))

count = 0
for op in 'EEENEEENEEESEEESEEENEEEN':
    if D.dim == D2_lst:
        print("Yes")
        break
    D.roll(op)
    count += 1
if count == 24:
    print("No")

Submission status: Accepted

Solution code:
#サイコロの問題C
class Dice:
    def __init__(self, input_dice):
        self.flow = [input_dice[3], input_dice[1], input_dice[0], input_dice[5], input_dice[2], input_dice[4]]
        self.dice = [input_dice[3], input_dice[1], input_dice[0], input_dice[5], input_dice[2], input_dice[4]]
  
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.dice[0] = n0
        self.dice[1] = n1
        self.dice[2] = n2
        self.dice[3] = n3
        self.dice[4] = n4
        self.dice[5] = n5
        return self.dice
    
    def roll(self, dir):
        if dir == 'S':
            self.setNumber(self.flow[0], self.flow[2], self.flow[5], self.flow[1], self.flow[4], self.flow[3])
            self.flow = self.dice
            return self.dice
        if dir == 'N':
            self.setNumber(self.flow[0], self.flow[3], self.flow[1], self.flow[5], self.flow[4], self.flow[2])
            self.flow = self.dice
            return self.dice
        if dir == 'W':
            self.setNumber(self.flow[2], self.flow[1], self.flow[4], self.flow[0], self.flow[3], self.flow[5])
            self.flow = self.dice
            return self.dice
        if dir == 'E':
            self.setNumber(self.flow[3], self.flow[1], self.flow[0], self.flow[4], self.flow[2], self.flow[5])
            self.flow = self.dice
            return self.dice

    def identify(self, dice_x):
        for i in range(6):
            if self.dice[i] != dice_x[i]:
                return False
                break
            elif i == 5:
                return True

    def check(self, dice_x):
        import sys
        dice_x = [dice_x[3], dice_x[1], dice_x[0], dice_x[5], dice_x[2], dice_x[4]]
        #以下メモ書き[1,2,3,4,5,6]の入力が与えられたとする
        #以下南北方向を軸に回転させる
        #最初2が前面
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        #1を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        #5を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        #6を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        #4を前面に持ってきて回転させる
        self.roll('E')
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        #3を前面に持ってきて回転させる
        self.roll('N')
        self.roll('N')
        for i in range(4):
            self.roll('W')
            if self.identify(dice_x) == True: 
                print('Yes')
                sys.exit()
        print('No')

dice = list(map(int, input().split()))
dice_x = list(map(int, input().split()))

d = Dice(dice)
d.check(dice_x)

Submission status: Accepted

Solution code:
class dice:
    def __init__(self, X):
        self.x = [0] * 6
        self.x[0] = X[0]
        self.x[1] = X[1]
        self.x[2] = X[2]
        self.x[3] = X[3]
        self.x[4] = X[4]
        self.x[5] = X[5]

    def roll(self, d):
        if d == 'S':
            self.x[0], self.x[1], self.x[4], self.x[5] = \
            self.x[4], self.x[0], self.x[5], self.x[1]
        elif d == 'E':
            self.x[0], self.x[2], self.x[3], self.x[5] = \
            self.x[3], self.x[0], self.x[5], self.x[2]
        elif d == 'W':
            self.x[0], self.x[2], self.x[3], self.x[5] = \
            self.x[2], self.x[5], self.x[0], self.x[3]
        elif d == 'N':
            self.x[0], self.x[1], self.x[4], self.x[5] = \
            self.x[1], self.x[5], self.x[0], self.x[4]

X1 = list(map(int, input().split()))
X2 = list(map(int, input().split()))
d1 = dice(X1)
d2 = dice(X2)
distances = list('NNNNWNNNWNNNENNNENNNWNNN')
b = False
for d in distances:
    d2.roll(d)
    if d1.x[0] == d2.x[0] and d1.x[1] == d2.x[1] and d1.x[2] == d2.x[2] and \
       d1.x[3] == d2.x[3] and d1.x[4] == d2.x[4] and d1.x[5] == d2.x[5]:
        b = True
        break
if b == False:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, list):
        self.list = list

    def roll_n(self):
        self.list = [self.list[1], self.list[5], self.list[2], self.list[3], self.list[0], self.list[4]]

    def roll_s(self):
        self.list = [self.list[4], self.list[0], self.list[2], self.list[3], self.list[5], self.list[1]]

    def roll_e(self):
        self.list = [self.list[3], self.list[1], self.list[0], self.list[5], self.list[4], self.list[2]]

    def roll_w(self):
        self.list = [self.list[2], self.list[1], self.list[5], self.list[0], self.list[4], self.list[3]]

    def rotate_r(self):
        self.list = [self.list[0], self.list[2], self.list[4], self.list[1], self.list[3], self.list[5]]


dice_1 = Dice(list(map(int, input().split())))
dice_2 = Dice(list(map(int, input().split())))
c = 0
for i in range(4):
    dice_1.rotate_r()
    for j in range(4):
        dice_1.roll_n()
        if dice_1.list == dice_2.list:
            c = 1

for i in range(4):
    dice_1.rotate_r()
    for j in range(4):
        dice_1.roll_e()
        if dice_1.list == dice_2.list:
            c = 1
if c == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import random

class Dice():
    def __init__(self, numbers):
        self.numbers = numbers
        S = [1, 5, 2, 3, 0, 4]
        N = [4, 0, 2, 3, 5, 1]
        W = [3, 1, 0, 5, 4, 2]
        E = [2, 1, 5, 0, 4, 3]
        self.tumble = {0: S, 1: N, 2: W, 3: E}
        
    def rol(self, command):
        prev = self.numbers.copy()
        for i, t in enumerate(self.tumble[command]):
            self.numbers[t] = prev[i]

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

max_len= 24
dice_table = []
dice = Dice(d1)


for _ in range(1000):
    dice.rol(random.randint(0, 3))
    numbers = dice.numbers.copy()
    if numbers not in dice_table:
        dice_table.append(numbers)
        
if d2 in dice_table:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

def dice():
    import random as ran

    dnum = list(map(int,input().split()))
    dcnum = list(map(int,input().split()))


    up = dnum[0]
    un = dnum[5]
    ri = dnum[2]
    le = dnum[3]
    fr = dnum[1]
    ba = dnum[4]
    tmp = int(0)
    tmp2 = int(0)
    order = ["S","N","E","W"]
    count = int(0)

    while count <= 1000  :
        x = ran.choice(order)
        if (x == "S"):
            tmp = fr
            tmp2 = un
            fr = up
            up = ba
            un = tmp
            ba = tmp2

        elif (x == "N"):
            tmp = un
            tmp2 = up
            up = fr
            un = ba
            fr = tmp
            ba = tmp2

        elif (x == "E"):
            tmp = up
            tmp2 = un
            up = le
            un = ri
            ri = tmp
            le = tmp2

        elif (x == "W"):
            tmp = un
            tmp2 = up
            up = ri
            un = le
            ri = tmp
            le = tmp2

        if (up == dcnum[0] and un == dcnum[5] and ri == dcnum[2] and le == dcnum[3] and fr == dcnum[1] and ba == dcnum[4]):
            print("Yes")
            break

        if (count == 1000):
            print("No")

        count += 1
dice()

Submission status: Accepted

Solution code:
# 9_A
# w = input().upper()
# t = ""
# while True:
#     tmp = input()
#     if tmp == "END_OF_TEXT":
#         break
#     t += tmp.upper() + " "
# list = t.split()
# print(list.count(w))

# 9_B
# while True:
#     t = input()
#     if t == "-":
#         break
#     m = int(input())
#     for i in range(m):
#         h = int(input())
#         t = t[h:] + t[:h]
#     print(t)

# 9_C
# n = int(input())
# score_t, score_h = 0, 0
# for i in range(n):
#     t, h = input().split()
#     if t > h:
#         score_t += 3
#     elif h > t:
#         score_h += 3
#     else:
#         score_t += 1
#         score_h += 1
# print(f"{score_t} {score_h}")

# 9_D
# t = str(input())
# o_list = []
# for i in range(int(input())):
#     o_list = input().split()
#     a, b = int(o_list[1]), int(o_list[2])
#     if o_list[0] == "print":
#         print(t[a : b + 1])
#     elif o_list[0] == "reverse":
#         t = t[:a] + t[a : b + 1][::-1] + t[b + 1 :]
#     elif o_list[0] == "replace":
#         t = t[:a] + o_list[3] + t[b + 1 :]

# 10_A
# import math

# x1, y1, x2, y2 = map(float, input().split())
# line = (x2 - x1) ** 2 + (y2 - y1) ** 2
# line = math.sqrt(line)
# print(line)

# 10_B
# import math

# a, b, c = map(float, input().split())
# h = b * math.sin(math.radians(c))
# print(h)

# 10_D
# https://qiita.com/shiroux/items/16173c1588d22e81333c
# import math

# n = int(input())
# x = list(map(int, input().split()))
# y = list(map(int, input().split()))
# p_1, p_2, p_3, p_infinit = 0, 0, 0, 0
# dis_list = []
# for i in range(n):
#     dis_list.append(abs(x[i] - y[i]))
#     sum_d = abs(x[i] - y[i])
#     p_1 += sum_d
#     p_2 += sum_d ** 2
#     p_3 += sum_d ** 3
# p_2 = math.sqrt(p_2)
# p_3 = p_3 ** (1 / 3)

# print(p_1)
# print(p_2)
# print(p_3)
# print(max(dis_list))

# 11_*
class Dice:
    def __init__(self, label: list):
        self.top, self.front, self.right, self.left, self.back, self.bottom = label

    def roll(self, direction: str):
        if direction == "N":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.front,
                self.bottom,
                self.right,
                self.left,
                self.top,
                self.back,
            )
        elif direction == "W":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.right,
                self.front,
                self.bottom,
                self.top,
                self.back,
                self.left,
            )
        elif direction == "S":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.back,
                self.top,
                self.right,
                self.left,
                self.bottom,
                self.front,
            )
        elif direction == "E":
            self.top, self.front, self.right, self.left, self.back, self.bottom = (
                self.left,
                self.front,
                self.top,
                self.bottom,
                self.back,
                self.right,
            )

    def output_top(self):
        print(self.top)

    def get_top_front(self):
        return f"{self.top} {self.front}"

    def print_right(self):
        print(self.right)

    def get_label(self):
        return [self.top, self.front, self.left, self.back, self.bottom]


# 11_A
# (*label,) = map(int, input().split())
# dice = Dice(label)
# for i in input():
#     dice.roll(i)
# dice.output_top()

# 11_B
# (*label,) = map(int, input().split())
# dice = Dice(label)
# q = int(input())
# for _ in range(q):
#     t, f = map(int, input().split())
#     for i in "EEEN" * 2 + "EEES" * 2 + "EEEN" * 2:
#         if f"{t} {f}" == dice.get_top_front():
#             dice.print_right()
#             break
#         dice.roll(i)

# 11_C
dice1 = list(map(int, input().split()))
dice2 = list(map(int, input().split()))
dice1 = Dice(dice1)
dice2 = Dice(dice2)

for i in "EEEN" * 2 + "EEES" * 2 + "EEEN" * 2:
    if dice1.get_label() == dice2.get_label():
        print("Yes")
        break
    dice1.roll(i)
else:
    print("No")

Submission status: Accepted

Solution code:
import sys


def rollDice(dice, direction):
    buf = [x for x in dice]
    if direction == "S":
        buf[0] = dice[4]
        buf[1] = dice[0]
        buf[4] = dice[5]
        buf[5] = dice[1]
    elif direction == "E":
        buf[0] = dice[3]
        buf[2] = dice[0]
        buf[3] = dice[5]
        buf[5] = dice[2]
    elif direction == "W":
        buf[0] = dice[2]
        buf[2] = dice[5]
        buf[3] = dice[0]
        buf[5] = dice[3]
    elif direction == "N":
        buf[0] = dice[1]
        buf[1] = dice[5]
        buf[4] = dice[0]
        buf[5] = dice[4]

    for i in range(6):
        dice[i] = buf[i]


def rollDiceSide(dice):
    buf = [x for x in dice]
    buf[1] = dice[2]
    buf[2] = dice[4]
    buf[3] = dice[1]
    buf[4] = dice[3]

    for i in range(6):
        dice[i] = buf[i]


def rollCheckSide(d):
    if d1 == d2:
        print("Yes")
        sys.exit()
    rollDiceSide(d2)


def rollCheck(d):
    if d1 == d2:
        print("Yes")
        sys.exit()
    rollDice(d2, "S")
    for _ in range(4):
        rollCheckSide(d2)


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


for _ in range(4):
    for _ in range(4):
        rollCheck(d2)
    rollDice(d2, "W")

print("No")

Submission status: Accepted

Solution code:
class dice:
    def __init__(self, f0, f1, f2, f3, f4, f5):
        self.dice_num = [f0, f1, f2, f3, f4, f5]

    def roll_dice(self, command):
        for i in command:
            if i == 'N':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[1]
                self.dice_num[1] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[4]
                self.dice_num[4] = tmp

            if i == 'S':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[4]
                self.dice_num[4] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[1]
                self.dice_num[1] = tmp

            if i == 'E':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[3]
                self.dice_num[3] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[2]
                self.dice_num[2] = tmp

            if i == 'W':
                tmp = self.dice_num[0]
                self.dice_num[0] = self.dice_num[2]
                self.dice_num[2] = self.dice_num[5]
                self.dice_num[5] = self.dice_num[3]
                self.dice_num[3] = tmp

    def print_topface(self):
        print(self.dice_num[0])

    def turn_clockwise(self):
        tmp = self.dice_num[1]
        self.dice_num[1] = self.dice_num[2]
        self.dice_num[2] = self.dice_num[4]
        self.dice_num[4] = self.dice_num[3]
        self.dice_num[3] = tmp

    def check_same_dice(self, dice2):
        for i in range(4):
            self.roll_dice('W')
            for j in range(4):
                self.turn_clockwise()
                if self.dice_num == dice2.dice_num:
                    return True
        for i in range(4):
            self.roll_dice('N')
            for j in range(4):
                self.turn_clockwise()
                if self.dice_num == dice2.dice_num:
                    return True
        return False


if __name__ == "__main__":
    num_list1 = list(map(int, input().split()))
    num_list2 = list(map(int, input().split()))
    mydice1 = dice(*num_list1)
    mydice2 = dice(*num_list2)
    same_dice = mydice1.check_same_dice(mydice2)
    if same_dice:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#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.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    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 equals(self,another):

        ret = False;

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret

diceA = Dice()
diceB = Dice()

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

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

if diceA.equals(diceB):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

class Dice:
    def __init__(self,lst):
        self.face=lst
        self.order="NNNNWNNNWNNNENNNENNNWNNN"
    
    def roll(self,x):
        tmp=self.face
        if x=="E":
            self.face=[tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        if x=="W":
            self.face=[tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        if x=="N":
            self.face=[tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]
        if x=="S":
            self.face=[tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
    
    def showDown(self):
        return self.face[0]
    
    def query(self,lst):
        tmp=self.face
        ans=-1
        for i in self.order:
            self.roll(i)
            if self.face[0]==lst[0] and self.face[1]==lst[1]:
                ans=self.face[2]
                break
        self.face=tmp
        return ans
    
    def isEqual(self,another):
        tmp=self.face
        ans=False
        for i in self.order:
            self.roll(i)
            flg=True
            for j in range(6):
                if self.face[j]!=another.face[j]:
                    flg=False
                    break
            if flg:
                return True

            
    
diceA=Dice(list(map(int,input().split(" "))))
diceB=Dice(list(map(int,input().split(" "))))
if diceA.isEqual(diceB):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, d1, d2, d3, d4, d5, d6):
        self.d1 = d1
        self.d2 = d2
        self.d3 = d3
        self.d4 = d4
        self.d5 = d5
        self.d6 = d6
    def S(self):
        tmp = self.d1
        self.d1 = self.d5
        self.d5 = self.d6
        self.d6 = self.d2
        self.d2 = tmp
    def N(self):
        tmp = self.d1
        self.d1 = self.d2
        self.d2 = self.d6
        self.d6 = self.d5
        self.d5 = tmp
    def E(self):
        tmp = self.d1
        self.d1 = self.d4
        self.d4 = self.d6
        self.d6 = self.d3
        self.d3 = tmp
    def W(self):
        tmp = self.d1
        self.d1 = self.d3
        self.d3 = self.d6
        self.d6 = self.d4
        self.d4 = tmp
    def comp(self, a, b, c):
        if (a == self.d1 and b == self.d2) or (a == self.d2 and b == self.d6) \
         or (a == self.d6 and b == self.d5) or (a == self.d5 and b == self.d1):
            if c == self.d3:
                return True
        if (a == self.d2 and b == self.d1) or (a == self.d6 and b == self.d2) \
         or (a == self.d5 and b == self.d6) or (a == self.d1 and b == self.d5):
            if c == self.d4:
                return True
        if (a == self.d1 and b == self.d3) or (a == self.d3 and b == self.d6) \
         or (a == self.d6 and b == self.d4) or (a == self.d4 and b == self.d1):
            if c == self.d5:
                return True
        if (a == self.d3 and b == self.d1) or (a == self.d6 and b == self.d3) \
         or (a == self.d4 and b == self.d6) or (a == self.d1 and b == self.d4):
            if c == self.d2:
                return True
        if (a == self.d2 and b == self.d3) or (a == self.d3 and b == self.d5) \
         or (a == self.d5 and b == self.d4) or (a == self.d4 and b == self.d2):
            if c == self.d1:
                return True
        if (a == self.d3 and b == self.d2) or (a == self.d5 and b == self.d3) \
         or (a == self.d4 and b == self.d5) or (a == self.d2 and b == self.d4):
            if c == self.d6:
                return True
        return False

d1, d2, d3, d4, d5, d6 = map(int, input().split())
dice = Dice(d1, d2, d3, d4, d5, d6)
d1, d2, d3, d4, d5, d6 = map(int, input().split())
OK = dice.comp(d1, d2, d3)
if OK:
    OK = dice.comp(d2, d6, d3)
if OK:
    OK = dice.comp(d6, d5, d3)
if OK:
    OK = dice.comp(d5, d1, d3)
if OK:
    OK = dice.comp(d2, d1, d4)
if OK:
    OK = dice.comp(d6, d2, d4)
if OK:
    OK = dice.comp(d5, d6, d4)
if OK:
    OK = dice.comp(d1, d5, d4)
if OK:
    OK = dice.comp(d1, d3, d5)
if OK:
    OK = dice.comp(d3, d6, d5)
if OK:
    OK = dice.comp(d6, d4, d5)
if OK:
    OK = dice.comp(d4, d1, d5)
if OK:
    OK = dice.comp(d3, d1, d2)
if OK:
    OK = dice.comp(d1, d4, d2)
if OK:
    OK = dice.comp(d4, d6, d2)
if OK:
    OK = dice.comp(d6, d3, d2)
if OK:
    OK = dice.comp(d2, d3, d1)
if OK:
    OK = dice.comp(d3, d5, d1)
if OK:
    OK = dice.comp(d5, d4, d1)
if OK:
    OK = dice.comp(d4, d2, d1)
if OK:
    OK = dice.comp(d3, d2, d6)
if OK:
    OK = dice.comp(d2, d4, d6)
if OK:
    OK = dice.comp(d4, d5, d6)
if OK:
    OK = dice.comp(d5, d3, d6)
if OK:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
class Dice:
  def __init__(self, list1):
    self.f = list1

  def spin1(self):  #(真上から見て反時計回り)
    f = self.f
    self.spin2()
    f[0], f[2], f[3], f[5] = f[3], f[0], f[5], f[2]
    f[0], f[1], f[4], f[5] = f[4], f[0], f[5], f[1]
    return f[:]

  def spin2(self):  #(方角Eから見て時計回り)
    f = self.f
    f[0], f[1], f[4], f[5] = f[1], f[5], f[0], f[4]
    return f[:]
    
  def spin3(self):  #(方角Sから見て半時計回り)
    f = self.f
    f[0], f[2], f[3], f[5] = f[2], f[5], f[0], f[3]
    return f[:]


data = list(map(int, input().split()))
dice_1 = Dice(data)

data_2 = [dice_1.spin2() for _ in range(4)]
for j in data_2[:]:
    dice_2 = Dice(j)
    data_2 += [dice_2.spin1() for _ in range(4)]

data_4 = []
for l in data_2:
    dice_3 = Dice(l)
    data_4 += [dice_3.spin3() for _ in range(4)]

data_1 = list(map(int, input().split()))
if data_1 in data_4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice:
  def __init__(self, list1):
    self.f = list1
  def spin1(self):#(真上から見て反時計回り)
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[3], self.f[0], self.f[5], self.f[2]
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[4], self.f[0], self.f[5], self.f[1]
    return self.f
  def spin2(self):#(方角Eから見て時計回り)
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    return self.f
  def spin3(self):#(方角Sから見て半時計回り)
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[2], self.f[5], self.f[0], self.f[3]
    return self.f

data = list(map(int, input().split()))
data_1 = list(map(int, input().split()))
data_2 = []
data_3 = []
data_4 = []
dice_1 = Dice(data)
for i in range(0, 4):
    a = dice_1.spin2()
    b = a[:]
    data_2.append(b)

for j in data_2:
    dice_2 = Dice(j)
    for k in range(0, 4):
        c = dice_2.spin1()
        d = c[:]
        data_3.append(d)
data_5 = data_2 + data_3

for l in data_5:
    dice_3 = Dice(l)
    for m in range(0, 4):
        e = dice_3.spin3()
        f = e[:]
        data_4.append(f)

if data_1 in data_4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import copy


class Dice:
    def __init__(self, eyes: [int]):
        self.__eyes = eyes

    @property
    def eyes(self):
        return self.__eyes

    def top(self):
        return self.__eyes[0]

    def right(self):
        return self.__eyes[2]

    def roll_s(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[4]
        tmp[1] = self.__eyes[0]
        tmp[2] = self.__eyes[2]
        tmp[3] = self.__eyes[3]
        tmp[4] = self.__eyes[5]
        tmp[5] = self.__eyes[1]
        self.__eyes = tmp

    def roll_e(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[3]
        tmp[1] = self.__eyes[1]
        tmp[2] = self.__eyes[0]
        tmp[3] = self.__eyes[5]
        tmp[4] = self.__eyes[4]
        tmp[5] = self.__eyes[2]
        self.__eyes = tmp

    def roll_n(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[1]
        tmp[1] = self.__eyes[5]
        tmp[2] = self.__eyes[2]
        tmp[3] = self.__eyes[3]
        tmp[4] = self.__eyes[0]
        tmp[5] = self.__eyes[4]
        self.__eyes = tmp

    def roll_w(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[2]
        tmp[1] = self.__eyes[1]
        tmp[2] = self.__eyes[5]
        tmp[3] = self.__eyes[0]
        tmp[4] = self.__eyes[4]
        tmp[5] = self.__eyes[3]
        self.__eyes = tmp

    def turn_right(self):
        tmp = copy.copy(self.__eyes)
        tmp[0] = self.__eyes[0]
        tmp[1] = self.__eyes[3]
        tmp[2] = self.__eyes[1]
        tmp[3] = self.__eyes[4]
        tmp[4] = self.__eyes[2]
        tmp[5] = self.__eyes[5]
        self.__eyes = tmp

    def adjust_top(self, top: int):
        for _ in range(4):
            if self.top() is top:
                break
            self.roll_e()
        for _ in range(4):
            if self.top() is top:
                break
            self.roll_s()

    def adjust_front(self, front: int):
        for _ in range(4):
            if self.front() is front:
                break
            self.turn_right()

    def front(self):
        return self.__eyes[1]

    def roll(self, direction: str):
        if direction.lower() == 'n':
            self.roll_n()
        if direction.lower() == 'e':
            self.roll_e()
        if direction.lower() == 's':
            self.roll_s()
        if direction.lower() == 'w':
            self.roll_w()


def resolve():
    eyes1 = list(map(int, input().split()))
    eyes2 = list(map(int, input().split()))

    dice1 = Dice(eyes1)
    dice2 = Dice(eyes2)

    random1 = max(set(eyes1+eyes2))

    dice1.adjust_top(random1)
    dice2.adjust_top(random1)

    dice2.adjust_front(dice1.front())

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



resolve()

Submission status: Accepted

Solution code:
dice1 = [int(i) for i in input().split()]
dice2 = [int(i) for i in input().split()]

if dice2[0] == dice1[1]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[1], dice1[5], dice1[0], dice1[4]
elif dice2[0] == dice1[2]:
    dice1[0], dice1[2], dice1[3], dice1[5] = dice1[2], dice1[5], dice1[0], dice1[3]
elif dice2[0] == dice1[3]:
    dice1[0], dice1[2], dice1[3], dice1[5] = dice1[3], dice1[0], dice1[5], dice1[2]
elif dice2[0] == dice1[4]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[4], dice1[0], dice1[5], dice1[1]
elif dice2[0] == dice1[5]:
    dice1[0], dice1[1], dice1[4], dice1[5] = dice1[5], dice1[4], dice1[1], dice1[0]

while dice2[1] != dice1[1]:
    dice1[1], dice1[2], dice1[4], dice1[3] = dice1[3], dice1[1], dice1[2], dice1[4]
    
if dice1 == dice2:
    print('Yes')
else:
    print('No')