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, lst):
        self.val=[]
        self.val.append(lst[0])
        self.val.append(lst[1])
        self.val.append(lst[2])
        self.val.append(lst[3])
        self.val.append(lst[4])
        self.val.append(lst[5])

    def rotate(self,dir):
        if dir=="N":
            tmp=self.val[0]
            self.val[0]=self.val[1]
            self.val[1]=self.val[5]
            self.val[5]=self.val[4]
            self.val[4]=tmp
        if dir=="E":
            tmp=self.val[0]
            self.val[0]=self.val[3]
            self.val[3]=self.val[5]
            self.val[5]=self.val[2]
            self.val[2]=tmp
        if dir=="S":
            tmp=self.val[0]
            self.val[0]=self.val[4]
            self.val[4]=self.val[5]
            self.val[5]=self.val[1]
            self.val[1]=tmp
        if dir=="W":
            tmp=self.val[0]
            self.val[0]=self.val[2]
            self.val[2]=self.val[5]
            self.val[5]=self.val[3]
            self.val[3]=tmp

def int_to_dir(n):
    if n==0:
        return "N"
    if n==1:
        return "E"
    if n==2:
        return "S"
    if n==3:
        return "W"
    

x = list(map(int,input().split()))
y = list(map(int,input().split()))

#print(x)
#print(y)

D1 = Dice(x) #generate instance

D2 = Dice(y)
#print(D1.val)
#print(D2.val)

import random 

Determin=False
for i in range(1000):

    D2.rotate(int_to_dir(random.randint(0,4)))
    
    #count+=1
    if D1.val==D2.val:
        #print(D1.val)
        #print(D2.val)
        Determin=True
        #print(i)
    
if Determin:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def dice_rotation(dice, command):

	tmp_dice = []
	
	for i in range(6):
		tmp_dice.append(dice[i])

	#S:1->2,2->6,6->5,5->1
	if command == 'S':
		dice[0] = tmp_dice[4]
		dice[4] = tmp_dice[5]
		dice[5] = tmp_dice[1]
		dice[1] = tmp_dice[0]
	#N:1->5,5->6,6->2,2->1
	elif command == 'N':
		dice[0] = tmp_dice[1]
		dice[1] = tmp_dice[5]
		dice[5] = tmp_dice[4]
		dice[4] = tmp_dice[0]
	#W:1->4,4->6,6->3,3->1
	elif command == 'W':
		dice[0] = tmp_dice[2]
		dice[2] = tmp_dice[5]
		dice[5] = tmp_dice[3]
		dice[3] = tmp_dice[0]
	#E:1->3,3->6,6->4,4->1
	elif command == 'E':
		dice[0] = tmp_dice[3]
		dice[3] = tmp_dice[5]
		dice[5] = tmp_dice[2]
		dice[2] = tmp_dice[0]

def dice_spinning(dice):

	tmp_dice = []
	
	for i in range(6):
		tmp_dice.append(dice[i])

	dice[1] = tmp_dice[2]
	dice[2] = tmp_dice[4]
	dice[4] = tmp_dice[3]
	dice[3] = tmp_dice[1]

def comparison_dices(Dice1,Dice2):

	yes_counter = 0
	for j in range(6):
		if Dice1[j] == Dice2[j]:
			yes_counter += 1
	if yes_counter == 6:
		return True

	return False

def test():

	Dice1 = list(map(int,input().split()))
	Dice2 = list(map(int,input().split()))

	judgement_result = False

	#1st direction
	for i in range(4):
		for j in range(4):
			if comparison_dices(Dice1,Dice2) == True:
				judgement_result = True
				break
			else:
				dice_spinning(Dice2)

		if judgement_result == True:
			break
		else:
			dice_rotation(Dice2,'S')

	#2nd direction
	for i in range(4):
		for j in range(4):
			if comparison_dices(Dice1,Dice2) == True:
				judgement_result = True
				break
			else:
				dice_spinning(Dice2)

		if judgement_result == True:
			break
		else:
			dice_rotation(Dice2,'W')

	if judgement_result == True:
		print("Yes")
	else:
		print("No")

if __name__ == "__main__":
	test()

Submission status: Accepted

Solution code:
import copy


class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

    def E(self):
        self.top, self.bottom, self.left, self.right = self.left, self.right, self.bottom, self.top

    def W(self):
        self.left, self.right, self.bottom, self.top = self.top, self.bottom, self.left, self.right

    def spin(self):
        self.left, self.behind, self.right, self.front = self.front, self.left, self.behind, self.right

    def __eq__(self, _dice2):
        dice2 = copy.deepcopy(_dice2)
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.N()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.E()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.W()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        dice2 = copy.deepcopy(_dice2)
        dice2.S()
        for i in range(4):
            if self._eqaul(dice2):
                return True
            dice2.spin()
        return False



    def _eqaul(self, dice2):
        return self.front == dice2.front and self.behind == dice2.behind and self.left == dice2.left and self.right == dice2.right and self.top == dice2.top and self.bottom == dice2.bottom

    def __repr__(self):
        return ",".join([str(object=i) for i in (self.top,self.front,self.right,self.left,self.behind,self.bottom)])

dice1 = Dice(*[int(i) for i in input().split(" ")])
dice2 = Dice(*[int(i) for i in input().split(" ")])

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

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,odr):
        if   odr=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif odr=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif odr=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif odr=='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()))
d1 = dice(label)
d2 = list(map(int, input().split()))
for odr in 'EEENEEENEEESEEESEEENEEEN':
    if d1.get_label() == d2:
        print('Yes')
        break
    d1.roll(odr)
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import copy
line = sys.stdin.readline() 
line = line.rstrip('\r\n')
face = line.split()

line = sys.stdin.readline() 
line = line.rstrip('\r\n')
face2 = line.split()


for i in range(5):
    if face[1] == face2[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
else:
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]
for i in range(5):
    if face[1] == face2[1]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[1]
    face[1] = face_old[5]
    face[2] = face_old[2]
    face[3] = face_old[3]
    face[4] = face_old[0]
    face[5] = face_old[4]
for i in range(5):
    if face[0] == face2[0]:
        break
    face_old = copy.deepcopy(face)
    face[0] = face_old[3]
    face[1] = face_old[1]
    face[2] = face_old[0]
    face[3] = face_old[5]
    face[4] = face_old[4]
    face[5] = face_old[2]

if face == face2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#ITP1_11_A

def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def spin(d):
	tmp=d[2]
	d[2]=d[3]
	d[3]=d[5]
	d[5]=d[4]
	d[4]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)

def inputDice():
	return list(map(int,("-1 "+input()).split()))

def equal(da, db):
	for op in list("NWWWN-"):
		for i in range(4):
			if(da[1]==db[1] and da[2]==db[2] and da[3]==db[3] and da[4]==db[4] and da[5]==db[5] and da[6]==db[6]):
				return True
			spin(db)
		kaiten(db,op)
	return False

da=inputDice()
db=inputDice()
if equal(da,db):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
class dice:
  def __init__(self,dice_number_list):
    self.top,self.front,self.right,self.left,self.rear,self.bottom = dice_number_list
    self.dice_number_list = dice_number_list
    
  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])
    
  #全パターン24通りの取得
  def get_all_number_list(self):
    #all_dice_number_list = []
    #while True:
    #  self.roll(random.choice("NEWS"))
    #  if self.get_label() not in all_dice_number_list:
    #    all_dice_number_list.append(self.get_label())
    #  if len(all_dice_number_list) == 24:
    #    return(all_dice_number_list)
    all_dice_number_list = []
    for op in "NNNNWNNNWNNNENNNENNNWNNN":
      self.roll(op)
      if self.get_label() not in all_dice_number_list:
        all_dice_number_list.append(self.get_label())
    return(all_dice_number_list)
  
  #2つのサイコロの一致判定
  def judge_equal(self,another):
    if(sorted(self.get_all_number_list()) == sorted(another.get_all_number_list())):
       return True
    else:
       return False

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

if d1.judge_equal(d2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

d,e=[input().split()for _ in'12'];e[3:5]=e[4],e[3]
t=0
for p in('012345','152304','215043','310542','402351','513240'):
 f=[d[int(j)]for j in p];f[3:5]=f[4:2:-1]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t])

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:
import sys
import os
import math
 
 
dice0 = list(map(int, input().split()))
dice1 = list(map(int, input().split()))
 
def dice_roll(dice, c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]
    return dice
 
 
def check():
    global dice0
    global dice1
 
    # up???????????????
    num = 0
    while dice0[0] != dice1[0]:
        if num % 2 == 0:
            dice0 = dice_roll(dice0, 'E')
        else:
            dice0 = dice_roll(dice0, 'N')
        num += 1
        if num > 10:
            return False
 
    # front???????????????
    num = 0
    while dice0[1] != dice1[1]:
        dice0 = dice_roll(dice0, 'R')
        num += 1
        if num > 10:
            return False
 
    if dice0[2] == dice1[2] and dice0[3] == dice1[3] and dice0[4] == dice1[4] and dice0[5] == dice1[5]:
        return True
    else:
        return False
 
result = check()
if result:
    print('Yes')
else:
    # ????????????
    dice0 = dice_roll(dice0, 'N')
    result = check()
    if result:
        print('Yes')
    else:
        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:
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.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
 
import random
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
u,s,e,w,n,d=map(int,input().split())
dice_b=Dice(u,w,s,e,n,d)
ok=False
for i in range (1000):
    dice.rot(random.randint(0,3))
    if(dice.u==dice_b.u and dice.d==dice_b.d and dice.w==dice_b.w and dice.s==dice_b.s and dice.e==dice_b.e and dice.n==dice_b.n):
        ok=True
if ok:
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
#! python3
# diceIII.py - サイコロを転がす動きをシミュレートするプログラム

import sys

def getKeyFromValue(dice, value):
    keys = [k for k, v in dice.items() if v == value]
    if keys:
        return keys[0]
    return None


def initDice(numbers):  # サイコロオブジェクトに値を入れる
        # サイコロオブジェクトを定義, 配列の数値を、各面にわたす
    dice = {'top': numbers[0], 'bottom': numbers[5], 'front': numbers[1],
            'back': numbers[4], 'right': numbers[2], 'left': numbers[3]}
    return dice


def rollDice(dice, direction):  # サイコロを転がしたときの関数
    if direction == 'N':
        top = dice['front']
        bottom = dice['back']
        front = dice['bottom']
        back = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'S':
        top = dice['back']
        bottom = dice['front']
        front = dice['top']
        back = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'E':
        top = dice['left']
        bottom = dice['right']
        right = dice['top']
        left = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    elif direction == 'W':
        top = dice['right']
        bottom = dice['left']
        right = dice['bottom']
        left = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    return dice


def spinDice(dice):
    front = dice['right']
    right = dice['back']
    back = dice['left']
    left = dice['front']
    dice['front'] = front
    dice['right'] = right
    dice['back'] = back
    dice['left'] = left
    return dice

def assertDice(dice_1, dice_2):
    if dice_1 == dice_2:
        print('Yes')
        sys.exit()

# 一つの目でやるチェックをまとめる
def checkDice(dice_1,dice_2):
    assertDice(dice_1, dice_2)
    # print('dice_1', dice_1)
    for i in range(3):
        dice_1 = spinDice(dice_1)
        # print('dice_1', dice_1)
        assertDice(dice_1, dice_2)

numbers_1 = [int(i) for i in input().split()]
dice_1 = initDice(numbers_1)
numbers_2 = [int(i) for i in input().split()]
dice_2 = initDice(numbers_2)

# サイコロを転がす前に、一回目のチェック
checkDice(dice_1,dice_2)

# サイコロの面を各1回ずつトップに持ってくるには5回転がす必要がある。
# サイコロは常に初期値にしておいて、転がす回数で、出す面を変えていく2次元配列で持つ

# 出す順番は以下の通り[front, back, right, left, bottom]
roll_directions = [['N'], ['S'], ['W'],['E'],['N','N']]

# print('初期値',dice_1)
# dice_1 = rollDice(dice_1, 'N')
# print('フロントがトップ',dice_1)
# checkDice(dice_1,dice_2)
# dice_1 = initDice(numbers_1)
# print('初期値2回め',dice_1)
dice_1 = initDice(numbers_1)

for direction in roll_directions:
    for d in direction:
        dice_1 = rollDice(dice_1, d)
    checkDice(dice_1,dice_2)
    dice_1 = initDice(numbers_1)

# if top_value_key == 'top':
#     pass
# elif top_value_key == 'right':
#     dice_1 = rollDice(dice_1, 'W')
# elif top_value_key == 'left':
#     dice_1 = rollDice(dice_1, 'E')
# elif top_value_key == 'front':
#     dice_1 = rollDice(dice_1, 'N')
# elif top_value_key == 'back':
#     dice_1 = rollDice(dice_1, 'S')
# else:
#     for i in range(2):
#         dice_1 = rollDice(dice_1, 'N')

# if dice_1['front'] != dice_2_front:
#     for i in range(3):
#         dice_1 = spinDice(dice_1)
#         if dice_1['front'] == dice_2_front:
#             break

# TODO : True が出るまですべての面を一度トップに持ってきて、スピンダイスで、回して、整合性を確認する
# 1 
# スピンする
# 2 [front] をトップにする（ロールダイスのN）
# スピンする
# 3 [right] をトップにする


# print(dice_1)
# print(dice_2)

print('No')

Submission status: Accepted

Solution code:
dai=list(map(int,input().split()))
daini=list(map(int,input().split()))
def kouten():
	x=dai[0]
	dai[0]=dai[1]
	dai[1]=dai[5]
	dai[5]=dai[4]
	dai[4]=x
def sokuten():
	x=dai[0]
	dai[0]=dai[2]
	dai[2]=dai[5]
	dai[5]=dai[3]
	dai[3]=x

def tokei():
	dai1 = dai[1]
	dai[1] = dai[2]
	dai[2] = dai[4]
	dai[4] = dai[3]
	dai[3] = dai1
def check():
	for j in range(4):
		if daini[0] == dai[0] and daini[1] == dai[1] and daini[2] == dai[2] and daini[3] == dai[3] and daini[4] == dai[4] and daini[5] == dai[5]:
			print('Yes')
			return True
		tokei()
	return False
for a in range(3):
	if not check():
		kouten()
	else:
	 break
	if not check():
		sokuten()
	else:
		break
	if a==2:
		print('No')

Submission status: Accepted

Solution code:
class Dice:
    # 0: top, 1: front, 2: right, 3: left, 4: back, 5: bottom
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

    def spin_horizontally(self):
        tmp = self.faces[1]
        self.faces[1] = self.faces[2]
        self.faces[2] = self.faces[4]
        self.faces[4] = self.faces[3]
        self.faces[3] = tmp

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

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

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

n_a = list(map(int, input().split()))
n_b = list(map(int, input().split()))
dice_a = Dice(n_a[0], n_a[1], n_a[2], n_a[3], n_a[4], n_a[5])
dice_b = Dice(n_b[0], n_b[1], n_b[2], n_b[3], n_b[4], n_b[5])

ans = 'No'
for i in range(6):

    if i % 2 == 0:
        dice_a.move('S')
    else:
        dice_a.move('E')

    if dice_a.top() == dice_b.top():
        for _ in range(4):
            dice_a.spin_horizontally()
            if dice_a.front() == dice_b.front():
                break

    if dice_a.faces == dice_b.faces:
        ans = 'Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,s):
        self.start = [0,1,2,4,3,5]#上 正 右 后 左 下
        self.s = s
        
    #下面的是几个反转方式
    def N(self):
        self.start[0],self.start[1],self.start[3],self.start[5] = \
        self.start[1],self.start[5],self.start[0],self.start[3]
        
    def S(self):
        self.start[0],self.start[1],self.start[3],self.start[5] = \
        self.start[3],self.start[0],self.start[5],self.start[1]
        
    def W(self):
        self.start[0],self.start[2],self.start[4],self.start[5] = \
        self.start[2],self.start[5],self.start[0],self.start[4]
    
    def E(self):
        self.start[0],self.start[2],self.start[4],self.start[5] = \
        self.start[4],self.start[0],self.start[5],self.start[2]    


    #这是特殊的旋转方法
    def roll(self):
        self.start[1],self.start[2],self.start[3],self.start[4] = \
        self.start[4],self.start[1],self.start[2],self.start[3]          
    
    def get_top(self):
        return self.s[self.start[0]]
    
    def get_zhengMian(self):
        return self.s[self.start[1]]
    
    def get_right(self):
        return self.s[self.start[2]]
    
    def get_left(self):
        return self.s[self.start[4]]  
    
def is_same(dice1,dice2):
    FLAG = False
    dice1 = Dice(dice1)
    dice2 = Dice(dice2)
    a,b,c = dice1.get_top(),dice1.get_zhengMian(),dice1.get_right()
    d,e,f = dice2.get_top(),dice2.get_zhengMian(),dice2.get_right()
    
    #我们在这只是转动dice2
    #让上面保持一致
    if d==a:
        FLAG = True
    elif d!=a:
        tmp1,tmp2 = dice2.get_left(),dice2.get_right()
        if tmp1==a:
            dice2.E()
            FLAG = True
        elif tmp2==a:
            dice2.W()
            FLAG = True
        else:
            count = 0
            while True:
                count += 1
                tmp1 = dice2.get_top()
                if tmp1==a:
                    FLAG = True
                    break
                if count == 4:
                    break
                dice2.S()
    
    #让正面保持一致
    if FLAG==False:
        return FLAG
    b,e = dice1.get_zhengMian(),dice2.get_zhengMian()
    if e==b:
        FLAG = True
    elif e!=b:
        count = 0
        while True:
            count += 1
            tmp = dice2.get_zhengMian()
            if tmp==b:
                FLAG = True
                break
            if count==4:
                FLAG = False
                break
            dice2.roll()
    
    if FLAG==False:
        return FLAG
    else:
        f = dice2.get_right()
        if f==c:
            return True
        else:
            return False

if __name__=="__main__":
    dice1 = list(map(int,input().split()))
    dice2 = list(map(int,input().split()))
    tmp1 = dice1.copy();tmp2 = dice2.copy()
    tmp1.sort();tmp2.sort()
    num = 0;
    for i in range(1,6):
        if tmp1[i-1]!=tmp1[i]:
            num += 1
    if num<=2:
        print('Yes')
    else:
        bl = is_same(dice1, dice2)
        if bl == True:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
d = list(map(int, input().split()))

rq = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for i in rq:
  if i == "E":
    d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
  elif i == "N":
    d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
  elif i == "S":
    d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
  elif i == "W":
    d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]

  if a == d:
      print("Yes")
      exit()

print("No")

Submission status: Accepted

Solution code:
import random
def dice(a,b,c,d,e,f,l):
    if l == "N":
        return [b,f,c,d,a,e]
    if l == "S":
        return [e,a,c,d,f,b]
    if l == "E":
        return [d,b,a,f,e,c]
    if l == "W":
        return [c,b,f,a,e,d]
d = list(map(int, input().split()))
s = ["W","N","E","S"]
a,b,c,g,e,f = map(int ,input().split())
j = 0
while j <= 10000:
    k = random.randrange(4)
    d = dice(d[0],d[1],d[2],d[3],d[4],d[5],s[k])
    if d[0] == a and d[1] == b and d[2] == c and d[3] == g and d[4] == e and d[5] == f:
        print("Yes")
        break
    if j == 10000:
        print("No")
    j += 1

Submission status: Accepted

Solution code:
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  #[0, 1, 2, 3, 4, 5]
        self.work = [i for i in range(6)]

    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 equal(self, dice):  # 自分と引数のサイコロが同一か判定
        directions = "EEEENEEEENEEEENEEEEWSEEEESSEEEE"  # サイコロの向きの全通りを試すための転がす命令（余分な転がしも含む）
        for d in directions:
            self.roll(d)
            for i in range(6):
                if self.number[i] != dice.number[i]:
                    break
                if i == 5:
                    return True
        return False

num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
dice1 = Dice()
dice1.setNumber(num1[0], num1[1], num1[2], num1[3], num1[4], num1[5])
dice2 = Dice()
dice2.setNumber(num2[0], num2[1], num2[2], num2[3], num2[4], num2[5])
if dice1.equal(dice2):
    print("Yes")
else:
    print("No")