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():
    top = 1
    flont = 2
    right = 3
    def do_N(self):
        temp = self.flont
        self.flont = 7-self.top
        self.top = temp

    def do_S(self):
        temp = 7-self.flont
        self.flont = self.top
        self.top = temp

    def do_E(self):
        temp = self.top
        self.top = 7-self.right
        self.right = temp

    def do_W(self):
        temp = 7-self.top
        self.top = self.right
        self.right = temp

num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
dice1 = dice()
dice2 = dice()
flag1 = False
flag2 = False

if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
    flag1 = True
    if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
        flag2 = True
for j in range(4):
    for k in range(4):
        dice1.do_E()
        if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
            flag1 = True
            if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
                flag2 = True
    dice1.do_N()
    if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
        flag1 = True
        if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
            flag2 = True

dice1.do_S()
dice1.do_E()
if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
    flag1 = True
    if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
        flag2 = True
for j in range(4):
    for k in range(4):
        dice1.do_E()
        if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
            flag1 = True
            if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
                flag2 = True
    dice1.do_N()
    if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
        flag1 = True
        if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
            flag2 = True

if flag1 and flag2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# ['表面', '南面', '東面', '西面', '北面', '裏面']
dice1 = [int(d) for d in input().split()]
dice2 = [int(d) for d in input().split()]

R1 = [
    [0, 1, 2, 3, 4, 5], # 移動なし
    [3, 1, 0, 5, 4, 2], # 東へ1
    [2, 1, 5, 0, 4, 3], # 西へ1
    [4, 0, 2, 3, 5, 1], # 南へ1
    [1, 5, 2, 3, 0, 4], # 北へ1
    [5, 4, 2, 3, 1, 0]  # 北へ2
]

R2 = [0, 3, 1, 4, 2, 5] # 水平回り1

ans = 'No'
for r1 in R1:
    dice3 = [dice2[i] for i in r1]
    for _ in range(4):
        dice3 = [dice3[i] for i in R2]
        if dice1 == dice3:
            ans = 'Yes'
            break
    else:
        continue
    break

print(ans)

Submission status: Accepted

Solution code:
def Roll(c, lst) :
    if c == 'N' :
        lst[0], lst[1], lst[5], lst[4] = lst[1], lst[5], lst[4], lst[0]
    elif c == 'S' :
        lst[0], lst[1], lst[5], lst[4] = lst[4], lst[0], lst[1], lst[5]
    elif c == 'E' :
        lst[0], lst[2], lst[5], lst[3] = lst[3], lst[0], lst[2], lst[5]
    elif c == 'W' :
        lst[0], lst[2], lst[5], lst[3] = lst[2], lst[5], lst[3], lst[0]
    return lst
    
import copy
dice_A = list(map(int, input().split()))
dice_B = list(map(int, input().split()))

for i in range(4) :
    if dice_B[1] == dice_A[1] :
        break
    else :
        Roll('S', dice_B)
if dice_B[1] != dice_A[1] :
    Roll('E', dice_B)
    for i in range(4) :
        if dice_B[1] == dice_A[1] :
            break
        else :
            Roll('S', dice_B)
for i in range(4) :
    if dice_B[0] == dice_A[0] :
        break
    else :
        Roll('E', dice_B)

if dice_B[2] == dice_A[2] and dice_B[3] == dice_A[3] and dice_B[4] == dice_A[4] and dice_B[5] == dice_A[5] :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, top: str, front: str, right: str, left: str, back: str, bottom: str) -> None:
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.back = back
        self.bottom = bottom

    def __eq__(self, other) -> bool:
        top, front = self.top, self.front

        # find top
        found = False
        for direction in 'SSSS':
            other.roll(direction)
            if other.top == top:
                found = True
                break
        if not found:
            for direction in 'EEE':
                other.roll(direction)
                if other.top == top:
                    break

        # find front
        for _ in range(4):
            other.rotate_right()
            if other.front == front:
                break

        return (
                self.right == other.right
                and self.left == other.left
                and self.back == other.back
                and self.bottom == other.bottom
        )

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

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

    def roll(self, direction: str) -> None:
        if direction == 'S':
            self.south()
        elif direction == 'N':
            self.north()
        elif direction == 'E':
            self.east()
        elif direction == 'W':
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]

    def east(self):
        [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]

    def west(self):
        [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]

    def rotate_right(self) -> None:
        for direction in 'SWN':
            self.roll(direction)


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

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

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self, a, b, c, d, e, f):
        """面の数字とindexを一致させるために0を挿入"""
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] #s[0]に一時的にs[1]を保持
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return
        
        elif dir == "R":
            self.s[0] = self.s[2]
            self.s[2] = self.s[3] 
            self.s[3] = self.s[5]
            self.s[5] = self.s[4]
            self.s[4] = self.s[0]
            return

        else:
            return


dice1 = Dice(*list(map(int, input().split())))
dice2 = Dice(*list(map(int, input().split())))
FLG = False

if set(dice1.s[1:]) != set(dice2.s[1:]):
    """片方にない数字がもう片方に含まれる場合"""
    pass 

elif dice1.s[1:] != dice2.s[1:]:
    for i in range(3):
        if dice1.s[1:] != dice2.s[1:]:
            for j in range(4):
                if dice1.s[1:] != dice2.s[1:]:
                    dice2.rotate("R")
                else:
                    FLG = True
                    break
            if FLG:
                break

            dice2.rotate("S")
            for j in range(4):
                if dice1.s[1:] != dice2.s[1:]:
                    dice2.rotate("R")
                else:
                    FLG = True
                    break
            if FLG:
                break
            dice2.rotate("E")
        else:
            FLG = True 
        if FLG:
            break
else:
    FLG = True

if FLG:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import copy


class Dice:
    def __init__(self, one: int, two: int, three: int, four: int, five: int, six: int) -> None:
        self.__one = one
        self.__two = two
        self.__three = three
        self.__four = four
        self.__five = five
        self.__six = six

    def roll(self, direction) -> None:
        if direction == "N":
            tmp = self.__one
            self.__one = self.__two
            self.__two = self.__six
            self.__six = self.__five
            self.__five = tmp

        if direction == "E":
            tmp = self.__one
            self.__one = self.__four
            self.__four = self.__six
            self.__six = self.__three
            self.__three = tmp

        if direction == "S":
            tmp = self.__one
            self.__one = self.__five
            self.__five = self.__six
            self.__six = self.__two
            self.__two = tmp

        if direction == "W":
            tmp = self.__one
            self.__one = self.__three
            self.__three = self.__six
            self.__six = self.__four
            self.__four = tmp

        if direction == "I":
            tmp = self.__one
            self.__one, self.__six = self.__six, self.__one
            self.__two, self.__five = self.__five, self.__two

    def set_top(self, top: int) -> bool:
        if self.__one != top:
            for i in range(3):
                self.roll("N")
                if (self.__one == top):
                    break
        if self.__one != top:
            for i in range(3):
                self.roll("E")
                if (self.__one == top):
                    break
        return self.__one == top

    def rotate(self) -> None:
        tmp = self.__two
        self.__two = self.__four
        self.__four = self.__five
        self.__five = self.__three
        self.__three = tmp

    def check(self, dice) -> bool:
        flag = True
        if self.__one != dice.__one:
            flag = False
        if self.__two != dice.__two:
            flag = False
        if self.__three != dice.__three:
            flag = False
        if self.__four != dice.__four:
            flag = False
        if self.__five != dice.__five:
            flag = False
        if self.__six != dice.__six:
            flag = False
        return flag

    @property
    def top(self) -> int:
        return self.__one

    @property
    def front(self) -> int:
        return self.__two

    @property
    def right(self) -> int:
        return self.__three

    @property
    def left(self) -> int:
        return self.__four

    @property
    def back(self) -> int:
        return self.__five

    @property
    def bottom(self) -> int:
        return self.__six


if __name__ == "__main__":
    dice1_one, dice1_two, dice1_three, dice1_four, dice1_five, dice1_six = map(
        int, input().split(' '))
    dice2_one, dice2_two, dice2_three, dice2_four, dice2_five, dice2_six = map(
        int, input().split(' '))

    dice1 = Dice(dice1_one, dice1_two, dice1_three,
                 dice1_four, dice1_five, dice1_six)
    dice2 = Dice(dice2_one, dice2_two, dice2_three,
                 dice2_four, dice2_five, dice2_six)

    directions = ["N", "E", "S", "W", "I"]
    for direction in directions:
        dice = copy.deepcopy(dice1)
        if not (dice1.top == dice2.top and dice1.bottom == dice2.bottom):
            dice.roll(direction)
        if dice.top == dice2.top and dice.bottom == dice2.bottom:
            if dice.front != dice2.front:
                for i in range(3):
                    dice.rotate()
                    if dice.check(dice2):
                        print("Yes")
                        exit()
            else:
                if dice.check(dice2):
                    print("Yes")
                    exit()
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

class Dice():
    
    #      e[4]
    # e[3] e[0] e[2] e[5]
    #      e[1]

    #      m[4]
    # m[3] m[0] m[2]
    #      m[1]
    #      m[5]
    
    def __init__(self, nums):
        self.pos = nums
    
    def rot_E(self):
        e = self.pos
        self.pos = [e[3], e[1], e[0], e[5], e[4], e[2]]

    def rot_W(self):
        e = self.pos
        self.pos = [e[2], e[1], e[5], e[0], e[4], e[3]]

    def rot_S(self):
        e = self.pos
        self.pos = [e[4], e[0], e[2], e[3], e[5], e[1]]

    def rot_N(self):
        e = self.pos
        self.pos = [e[1], e[5], e[2], e[3], e[0], e[4]]
        
    def rot_CW(self):
        e = self.pos
        self.pos = [e[0], e[2], e[4], e[1], e[3], e[5]]

    def rot_CCW(self):
        e = self.pos
        self.pos = [e[0], e[3], e[1], e[4], e[2], e[5]]

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

    def face(self):
        return self.pos[1]

    def right(self, tf=None):
        # tf = (t,f) : 上面 / 正面のラベル

        if tf == None:
            print(self.pos[2])
            return

        t = self.pos.index(tf[0])  # 上面（の扱いになっている）のラベルを取得
        f = self.pos.index(tf[1])  # 前面（の扱いになっている）のラベルを取得
        
        # u,f,r
        dr = [(1,2,4,3),(0,3,5,2),(0,1,5,4),(0,4,5,1),(0,2,5,3),(1,3,4,2)]
        r = (dr[t].index(f) + 1) % 4
        print(self.pos[dr[t][r]])
        return

    def left(self):
        print(self.pos[3])
        return

    def back(self):
        print(self.pos[4])
        return

    def bottom(self):
        print(self.pos[5])
        return

    def fit_top(x):
        if x == 0:
            d2.rot_S()
            d2.rot_S()
        if x == 1:
            d2.rot_N()
        if x == 3:
            d2.rot_axis()
            d2.rot_axis()
        if x == 4:
            d2.rot_S()
        if x == 5:
            d2.rot_axis()
            d2.rot_axis()
            d2.rot_axis()

    
    def position(self, x):
        return self.pos.index(x)
    
# 各方向を総当りでチェックする

d1 = Dice([int(x) for x in input().split()])
d2 = Dice([int(x) for x in input().split()])

check_f = False
# 上面からスタート

for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True

d2.rot_N()
for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True
d2.rot_S()

d2.rot_W()
for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True
d2.rot_E()

d2.rot_S()
for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True
d2.rot_N()

d2.rot_E()
for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True
d2.rot_W()

d2.rot_E()
d2.rot_E()
for _ in range(4):
    d2.rot_CW()
    if d1.pos == d2.pos:
        check_f = True
d2.rot_W()
d2.rot_W()

if check_f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, lst):
        self.a = lst[0]
        self.b = lst[1]
        self.c = lst[2]
        self.d = lst[3]
        self.e = lst[4]
        self.f = lst[5]
        
    def roll(self, orders):
        for order in orders:
            if order=='W':
                tmp = self.a
                self.a = self.c
                self.c = self.f
                self.f = self.d
                self.d = tmp
            elif order=='E':
                tmp = self.a
                self.a = self.d
                self.d = self.f
                self.f = self.c
                self.c = tmp
            elif order=='S':
                tmp = self.a
                self.a = self.e
                self.e = self.f
                self.f = self.b
                self.b = tmp
            elif order=='N':
                tmp = self.a
                self.a = self.b
                self.b = self.f
                self.f = self.e
                self.e = tmp
#             print(self.a, self.b, self.c, self.d, self.e, self.f)
#         print(self.a)
    
    def equal(self, dice_):
        if (self.a==dice_.a and
            self.b==dice_.b and
            self.c==dice_.c and
            self.d==dice_.d and
            self.e==dice_.e and
            self.f==dice_.f
           ):
            return True
        else:
            return False
       
            
import random
if __name__ == '__main__':
    lsts = [[int(x) for x in input().split()] for _ in range(2)]
    dice1 = Dice(lsts[0])
    dice2 = Dice(lsts[1])
    
    ans = 'No'
    for direction in 'EEENEEENEEESEEESEEENEEEN':
        if dice1.equal(dice2):
            ans = 'Yes'
            break
        else:
            dice1.roll(direction)
    print(ans)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.face = {'head':1, 'tail':4, 'left':3, 'right':2, 'above':0, 'below':5}
    
    def roll(self, ch):
        dice = self.dice
        face = self.face
        if ch == 'S':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['above']]
            dice[face['above']] = dice[face['tail']]
            dice[face['tail']] = dice[face['below']]
            dice[face['below']] = tmp
        elif ch == 'N':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['below']]
            dice[face['below']] = dice[face['tail']]
            dice[face['tail']] = dice[face['above']]
            dice[face['above']] = tmp
        elif ch == 'W':
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['above']]
            dice[face['above']] = dice[face['right']]
            dice[face['right']] = dice[face['below']]
            dice[face['below']] = tmp
        else:
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['below']]
            dice[face['below']] = dice[face['right']]
            dice[face['right']] = dice[face['above']]
            dice[face['above']] = tmp

    def top(self):
        dice = self.dice
        face = self.face
        return dice[face['above']]
    
    def find_right(self, a, b):
        dice = self.dice
        face = self.face
        order = 'NNNNWNNNWNNNENNNENNNWNNN'
        for ch in order:
            self.roll(ch)
            if dice[face['above']] == a and dice[face['head']] == b:
                break
        return dice[face['right']]

    def equal(self, dice2):
        dice = self.dice
        dice2 = dice2.dice
        tag = False
        order = 'NNNNWNNNWNNNENNNENNNWNNN'
        for ch in order:
            self.roll(ch)
            flag = True
            for i in range(6):
                if dice[i] != dice2[i]:
                    flag = False
                    break
            if flag:
                tag = flag
                break
        return tag

dice = Dice([*map(int, input().split())])
dice2 = Dice([*map(int, input().split())])
print(['No','Yes'][dice.equal(dice2)])

Submission status: Accepted

Solution code:
class dice():
    def __init__(self,labels):
        self.l=labels
    def check(self,d2):
        l1=self.l
        for a in range(4):
            l1[1],l1[2],l1[3],l1[4]=l1[2],l1[4],l1[1],l1[3]
            for b in range(4):
                l1[0],l1[3],l1[2],l1[5]=l1[2],l1[0],l1[5],l1[3]
                for c in range(4):
                    l1[0],l1[1],l1[5],l1[4]=l1[4],l1[0],l1[1],l1[5]
                    if l1==d2.l:
                        return True
                        break
a=dice([int(i) for i in input().split()])
b=dice([int(i) for i in input().split()])
print("Yes" if a.check(b) else "No")

Submission status: Accepted

Solution code:
roll_dict = dict(E = (3, 1, 0, 5, 4, 2), W = (2, 1, 5, 0, 4, 3), S = (4, 0, 2, 3, 5, 1), N = (1, 5, 2, 3, 0, 4))

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

dices = []
dices.append(dice1)
judge = False

for i in "EWSN":
  dice = dices[0]
  new_dice = []
  for j in range(6):
    new_dice.append(dice[ roll_dict[i][j] ])
  dices.append(new_dice)

dice = dices[1]
new_dice = []
for i in range(6):
  new_dice.append(dice[ roll_dict["E"][i] ])
dices.append(new_dice)

for i in range(6):
  if dices[i][0] == dice2[0] and dices[i][5] == dice2[5]:
    str_dice1 = "".join(map(str, dices[i]))
    str_dice2 = "".join(map(str, dice2))

    side1 = str_dice1[1:3]+str_dice1[4]+str_dice1[3]
    side1 += side1
    side2 = str_dice2[1:3]+str_dice2[4]+str_dice2[3]

    judge = side2 in side1

if judge == True:
  print("Yes")
elif judge == False:
  print("No")

Submission status: Accepted

Solution code:
# Problem - サイコロⅢ

t, s, e, w, n, b = map(int, input().split())
t_2, s_2, e_2, w_2, n_2, b_2 = map(int, input().split())

# initialization
dice_dic = {}
dice_dic[t] = {s:e, e:n, n:w, w:s}
dice_dic[b] = {n:e, w:n, s:w, e:s}
dice_dic[s] = {e:t, t:w, w:b, b:e}
dice_dic[n] = {t:e, e:b, b:w, w:t}
dice_dic[e] = {s:b, b:n, n:t, t:s}
dice_dic[w] = {s:t, t:n, n:b, b:s}

dice_dic_2 = {}
dice_dic_2[t_2] = {s_2:e_2, e_2:n_2, n_2:w_2, w_2:s_2}
dice_dic_2[b_2] = {n_2:e_2, w_2:n_2, s_2:w_2, e_2:s_2}
dice_dic_2[s_2] = {e_2:t_2, t_2:w_2, w_2:b_2, b_2:e_2}
dice_dic_2[n_2] = {t_2:e_2, e_2:b_2, b_2:w_2, w_2:t_2}
dice_dic_2[e_2] = {s_2:b_2, b_2:n_2, n_2:t_2, t_2:s_2}
dice_dic_2[w_2] = {s_2:t_2, t_2:n_2, n_2:b_2, b_2:s_2}

is_ok = True

for k in dice_dic:
    for k_2 in dice_dic[k]:
        if k_2 in dice_dic_2[k]:
            if not dice_dic[k][k_2]==dice_dic_2[k][k_2]:
                is_ok = False
                break
        else:
            is_ok = False
            break

# output
if is_ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
dice1 = input().rstrip().split(' ')
dice2 = input().rstrip().split(' ')
indication = "EEENEEENEEESEEESEEENEEENSWWSWWWNWWWNWWWSWWWSWWW"
indic = list(indication)
length = len(indic)
count =0
for i in range(length):
  newdice = [0] * 6
  if str(indic[i]) == "N":
    newdice[0] = dice2[1]
    newdice[1] = dice2[5]
    newdice[2] = dice2[2]
    newdice[3] = dice2[3]
    newdice[4] = dice2[0]
    newdice[5] = dice2[4]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "S":
    newdice[0] = dice2[4]
    newdice[1] = dice2[0]
    newdice[2] = dice2[2]
    newdice[3] = dice2[3]
    newdice[4] = dice2[5]
    newdice[5] = dice2[1]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "E":
    newdice[0] = dice2[3]
    newdice[1] = dice2[1]
    newdice[2] = dice2[0]
    newdice[3] = dice2[5]
    newdice[4] = dice2[4]
    newdice[5] = dice2[2]
    dice2 = newdice
    if dice2 == dice1:
      count += 1
  elif str(indic[i]) == "W":
    newdice[0] = dice2[2]
    newdice[1] = dice2[1]
    newdice[2] = dice2[5]
    newdice[3] = dice2[0]
    newdice[4] = dice2[4]
    newdice[5] = dice2[3]
    dice2 = newdice
    if dice2 == dice1:
      count += 1

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

Submission status: Accepted

Solution code:
from copy import deepcopy

class Dice():

    def __init__(self):
        self.E = [4,2,1,6,5,3]
        self.N = [2,6,3,4,1,5]
        self.S = [5,1,3,4,6,2]
        self.W = [3,2,6,1,5,4]
        self.number = list(map(int,input().split()))
        ##self.order = "NNNNWNNNWNNNENNNENNNWNNN"

    def rotate(self,order):
        tmp = deepcopy(self.number)
        if order == "E":
            for i in range(6):
                self.number[i] = tmp[self.E[i]-1]
        elif order == "N":
            for i in range(6):
                self.number[i] = tmp[self.N[i]-1]
        elif order == "S":
            for i in range(6):
                self.number[i] = tmp[self.S[i]-1]
        elif order == "W":
            for i in range(6):
                self.number[i] = tmp[self.W[i]-1]
    
    def sidenum(self,x,y):
        for i in self.order:
            if self.number[1] == y and self.number[0] == x:
                print(self.number[2])
                break
            else:
                self.rotate(i)
    
    def check(self,other):
        flag = True
        for i in range(6):
            if self.number[i] != other.number[i]:
                flag = False
        return flag

if __name__ == "__main__":
    flag = False
    dice1 = Dice()
    dice2 = Dice()
    order = "NNNNWNNNWNNNENNNENNNWNNN"
    for i in order:
        dice1.rotate(i)
        if dice1.check(dice2):
            flag = True
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

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

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

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

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

    def roll(self,command):
        if command=='N':self.roll_n()
        if command=='E':self.roll_e()
        if command=='S':self.roll_s()
        if command=='W':self.roll_w()

    def same(self,b):
        com1 = 'SSSWSSSE'
        com2 = 'WWWW'
        for c in com1:
            if self.dice[1]==b.dice[1]:break
            if c=='E':return False
            b.roll(c)
        for c in com2:
            if self.dice==b.dice:return True
            b.roll(c)
        return False

def main():
    a = dice(list(map(int,input().split())))
    b = dice(list(map(int,input().split())))
    if a.same(b):print('Yes')
    else        :print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import random 

def dice (a, b, c, d, e, f, l) :  #def = 関数定義 

  if(l == "N") : 

    return [b, f, c, d, a, e] 

  elif (l == "S") : 

    return [e, a, c, d, f, b] 

  elif (l == "W") : 

    return [d, b, a, f, e, c] 

  else : 

    return [c, b, f, a, e, d] 

  

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

a, b, c, d, e, f = map(int, input().split()) 

L = ["N", "S", "W", "E"] 

  

cnt = 0 

  

while (cnt <= 10000) : 

  x = random.randrange(4)  #0～3の中からランダムに1つ整数を選択 

  d1 = dice(d1[0], d1[1], d1[2], d1[3], d1[4], d1[5], L[x]) 

  

  if (d1[0] == a and d1[1] == b and d1[2] == c and d1[3] == d 

     and d1[4] == e and d1[5] == f) : 

    print("Yes") 

    break 

  elif (cnt == 10000) : 

    print ("No") 

    break 

  else : 

    cnt += 1

Submission status: Accepted

Solution code:
def dice(d, n):
    if n == 1:
        return d[1] + d[2] + d[4] + d[3]
    if n == 2:
        return d[0] + d[3] + d[5] + d[2]
    if n == 3:
        return d[0] + d[1] + d[5] + d[4]
    if n == 4:
        return d[0] + d[4] + d[5] + d[1]
    if n == 5:
        return d[0] + d[2] + d[5] + d[3]
    if n == 6:
        return d[1] + d[3] + d[4] + d[2]

d1 = input().split()
d2 = input().split()

for i in range(6):
    if d1[0] == d2[i] and d1[5] == d2[5-i] and dice(d2, i+1) in dice(d1, 1)*2:
        print('Yes')
        break
    if i == 5:
        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 roll(self,c):
        if c=='N':
            self.d1,self.d5,self.d6,self.d2=self.d2,self.d1,self.d5,self.d6
        elif c=='S':
            self.d1,self.d5,self.d6,self.d2=self.d5,self.d6,self.d2,self.d1
        elif c=='E':
            self.d1,self.d3,self.d6,self.d4=self.d4,self.d1,self.d3,self.d6
        elif c=='W':
            self.d1,self.d3,self.d6,self.d4=self.d3,self.d6,self.d4,self.d1
        elif c=='R':
            self.d2,self.d3,self.d5,self.d4=self.d4,self.d2,self.d3,self.d5
        elif c=='L':
            self.d2,self.d3,self.d5,self.d4=self.d3,self.d5,self.d4,self.d2
    
    def minnum(self):
        return min(self.d1,self.d2,self.d3,self.d4,self.d5,self.d6)
        
    def min2num(self):
        return min(self.d2,self.d3,self.d4,self.d5,self.d6)
        
    def rolling(self):
        m=self.minnum()
        if m==self.d3:
            self.roll('W')
        elif m==self.d6:
            self.roll('E')
            self.roll('E')
        elif m==self.d4:
            self.roll('E')
        elif m==self.d2:
            self.roll('N')
        elif m==self.d5:
            self.roll('S')
        m=self.min2num()
        if m==self.d3:
            self.roll('L')
        elif m==self.d5:
            self.roll('L')
            self.roll('L')
        elif m==self.d4:
            self.roll('R')
            
    def returnlist(self):
        l=[self.d1,self.d2,self.d3,self.d4,self.d5,self.d6]
        return l
    
a,b,c,d,e,f=map(int,input().split())
D=Dice(a,b,c,d,e,f)
a,b,c,d,e,f=map(int,input().split())
D2=Dice(a,b,c,d,e,f)
D.rolling()
D2.rolling()
if D.returnlist()==D2.returnlist():
    print("Yes")
else:
    print("No")