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:
a=[int(i)-1 for i in input().split()]
b=[int(i)-1 for i in input().split()]

for _ in range(4):
    b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5]
    for _ in range(4):
        b[1],b[2],b[4],b[3]=b[3],b[1],b[2],b[4]
        for _ in range(4):
            b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5]
            if a==b:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

Solution code:
class Dice :
    def __init__(self, pane):
        self.pane = pane
    
    def roll_W(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[2]
        self.pane[2] = self.pane[5]
        self.pane[5] = self.pane[3]
        self.pane[3] = temp

    def roll_S(self):
        temp = self.pane[0]
        self.pane[0] = self.pane[4]
        self.pane[4] = self.pane[5]
        self.pane[5] = self.pane[1]
        self.pane[1] = temp
    
dice1 = Dice(input().split())
dice2 = Dice(input().split())

flag = True

while True:
    t = dice1.pane[0]
    f = dice1.pane[1]
    if (dice2.pane[0] == f or dice2.pane[4] == f):
        dice2.roll_S()
    if (dice2.pane[0] == t and dice2.pane[1] == f):
        break
    dice2.roll_W()

for i in range(0, len(dice1.pane)):
    if (dice1.pane[i] != dice2.pane[i]):
        flag = False
        break

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

Submission status: Accepted

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

class Dice:
    def __init__(self,dice):
        self.dice = dice
    def n_roll(self):
        self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
    def s_roll(self):
        self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
    def e_roll(self):
        self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]
    def w_roll(self):
        self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
    def r_spin(self):
        self.dice = [self.dice[0],self.dice[2],self.dice[4],self.dice[1],self.dice[3],self.dice[5]]

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))
flag = 0
for i in range(4):
        dice1.n_roll()
        for j in range(4):
            dice1.r_spin()
            if dice2.dice == dice1.dice:
                flag = 1
for i in range(4):
        dice1.w_roll()
        for j in range(4):
            dice1.r_spin()
            if dice2.dice == dice1.dice:
                flag = 1


if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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


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

check = "No"
for x in "EEENEEENEEESEEESEEENEEEN":
    if d1.pip == d2.pip:
        check = "Yes"
        break
    d2.move(x)
print(check)

Submission status: Accepted

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

    def toN(self):
        tmp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = tmp

    def toS(self):
        tmp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = tmp

    def toE(self):
        tmp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = tmp

    def toW(self):
        tmp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = tmp

    def moveTo(self, ds):
        for d in ds:
            if   d == 'N':
                self.toN()
            if d == 'S':
                self.toS()
            if d == 'E':
                self.toE()
            if d == 'W':
                self.toW()

    def getTop(self):
        return self.top

    def getBottom(self):
        return self.bottom

    def getFront(self):
        return self.front

    def getBack(self):
        return self.back

    def getLeft(self):
        return self.left

    def getRight(self):
        return self.right

    def __eq__(self, other):
        if self.top != other.top:
            return False
        if self.bottom != other.bottom:
            return False
        if self.front != other.front:
            return False
        if self.back != other.back:
            return False
        if self.left != other.left:
            return False
        if self.right != other.right:
            return False

        return True

def moveTo(dice, top, front):
    if dice.getFront() != front:
        if   dice.getTop()    == front:
            dice.moveTo("S")
        elif dice.getBottom() == front:
            dice.moveTo("N")
        elif dice.getBack()   == front:
            dice.moveTo("NN")
        elif dice.getLeft()   == front:
            dice.moveTo("ES")
        elif dice.getRight()  == front:
            dice.moveTo("WS")

    if dice.getTop() != top:
        if   dice.getBottom() == top:
            dice.moveTo("EE")
        elif dice.getLeft()   == top:
            dice.moveTo("E")
        elif dice.getRight()  == top:
            dice.moveTo("W")

    return dice

def equalDice(dice1, dice2):
    dice2 = moveTo(dice2, dice1.getTop(), dice1.getFront())
    return dice1 == dice2

def main():
    dice1 = Dice(input().split())
    dice2 = Dice(input().split())

    if equalDice(dice1, dice2):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
class Dice:
  def __init__(self, top=1, front=2, left=4, right=3, back=5, bottom=6):
    self.d = {"TOP":top, "FRONT":front, "LEFT":left, "RIGHT":right, "BACK":back, "BOTTOM":bottom}

  def roll_x(self):
    self._roll("TOP", "FRONT", "BOTTOM", "BACK")
  
  def roll_y(self):
    self._roll("FRONT", "LEFT", "BACK", "RIGHT")
  
  def roll_z(self):
    self._roll("TOP", "LEFT", "BOTTOM", "RIGHT")
  
  def _roll(self, a, b, c, d):
    self.d[a], self.d[b], self.d[c], self.d[d] = \
    self.d[b], self.d[c], self.d[d], self.d[a]
  
  def all_rolls(self):
    ret = []
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for j in range(4):
        self.roll_z()
        t = self.d.copy()
        ret.append(t)
    return ret

  def equivalent(self, dice):
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for j in range(4):
        self.roll_z()
        t = self.d.copy()
        if t==dice.d:
          return True
    return False

d1 = list(map(int, input().split()))
dd1 = Dice(d1[0], d1[1], d1[3], d1[2], d1[4], d1[5])
d2 = list(map(int, input().split()))
dd2 = Dice(d2[0], d2[1], d2[3], d2[2], d2[4], d2[5])
if dd1.equivalent(dd2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
class Dice:
	# Label: 1=Up, 2=South, 3=East, 4=West, 5=North, 6=Down
	def __init__(self, nums):
		self.nums = nums
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
	def toU(self, num):
		if self.cD == num:
			for _ in range(2): self.goN()
		elif self.cN == num: self.goS()
		elif self.cE == num: self.goW()
		elif self.cW == num: self.goE()
		elif self.cS == num: self.goN()
	def right(self, num):
		if self.cN == num: return self.cW
		elif self.cE == num: return self.cN
		elif self.cW == num: return self.cS
		elif self.cS == num: return self.cE
		else: raise # ????????????
di1 = Dice([int(i) for i in input().split(' ')])
di2 = Dice([int(i) for i in input().split(' ')])
for i in di1.nums:
	if di2.nums.count(i) == 1:
		di1.toU(i)
		di2.toU(i)
		break
if di1.cU == di2.cU and di1.cD == di2.cD:
	nesw1 = ''.join(list(map(str, [di1.cN,di1.cE,di1.cS,di1.cW])))
	nesw1 += nesw1
	nesw2 = ''.join(list(map(str, [di2.cN,di2.cE,di2.cS,di2.cW])))
	if nesw1.count(nesw2) > 0: print('Yes')
	else: print('No')
else: print('No')

Submission status: Runtime Error

Solution code:
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def move_next_rows(self):
        temp = self.rows.pop(0)
        self.rows.append(temp)
        self.__update(self.cols, self.rows)

    def move_prev_rows(self):
        temp = self.rows.pop(3)
        self.rows.insert(0, temp)
        self.__update(self.cols, self.rows)
    
    def move_next_cols(self):
        temp = self.cols.pop(0)
        self.cols.append(temp)
        self.__update(self.rows, self.cols)
 
    def move_prev_cols(self):
        temp = self.cols.pop(3)
        self.cols.insert(0, temp)
        self.__update(self.rows, self.cols)

    def __update(self, x, y):
        x[0] = y[0]
        x[2] = y[2]
 
class DiceChecker(object):

    def __init__(self, dice1, dice2):
        self.dice1 = dice1
        self.dice2 = dice2
        self.dice1_top = self.dice1.rows[0]
        self.dice1_front = self.dice1.rows[3]
        
    def check_same_dice(self):

        self.__find_num(self.dice1_top, self.dice2)
        if self.dice1_front not in self.dice2.rows:
            self.dice2.move_prev_cols()  
            self.__find_num(self.dice1_front, self.dice2)
        
         while self.dice1_top != self.dice2.rows[0]:
            self.dice2.move_next_rows()
        is_same = False
        for _ in range(4):
            for _ in range(4):
                is_same_element = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                self.__rot(self.dice2)
                is_rot_same = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                
                if is_same_element or is_rot_same: 
                    is_same = True
                else:
                    is_same = False
                self.dice2.move_next_cols()     
            self.dice2.move_next_rows()
        
        if is_same:
            print("Yes")
        else:
            print("No")
    def __find_num(self, x, dice):
        i = 0
        while x != dice.rows[0]:
            dice.move_next_rows()
            if i > 3:
                dice.move_next_cols()
                i = 0
            i+=1
    
    def __rot(self, dice):
        temp = dice.rows[1]
        dice.rows[1] = dice.rows[3]
        dice.rows[3] = temp

        temp = dice.cols[1]
        dice.cols[1] = dice.cols[3]
        dice.cols[3] = temp

        
d1 = list(map(int, input().split(" ")))
d2 = list(map(int, input().split(" ")))
dice1 = Dice(d1)
dice2 = Dice(d2)

dice_checker = DiceChecker(dice1, dice2)
dice_checker.check_same_dice()

Submission status: Runtime Error

Solution code:
class Dice :
        same_dice_index = ('123456' , '135246' , '142536' , '154326' ,
                       '214365' , '231645' , '246135' , '263415',
                       '312564' , '326154' , '351624' , '365214',
                       '415263' , '421653' , '456123' , '462513',
                       '513462' , '536142' , '541632' , '564312',
                       '624351' , '632541' , '645231' , '653421')

def __init__ ( self , num_list ) :
            self.faces = num_list

 
    

def is_same ( self , dice ) :
            for i in Dice.same_dice_index :
                    example_faces = [ ]

            for j in i :
                    example_faces.append ( self.faces [ int ( j ) - 1 ] )
            if example_faces == dice.faces :
                    return 'Yes'
        return 'No'
 
num_list1 = list ( map ( int , input ( ).split ( ) ) )
num_list2 = list ( map ( int , input ( ).split ( ) ) )
 
dice1 = Dice ( num_list1 )
dice2 = Dice ( num_list2 )
 
ans = dice1.is_same ( dice2 )
 
print ( ans )

Submission status: Runtime Error

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: Runtime Error

Solution code:
#!/usr/bin/env python3
# coding: utf-8

class Dice() :

    mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),
            'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}

    way = ("N","E","W","S","CW","Nop")

    def __init__(self, data):
        self.label = data

    def move(self, data):
        if data == "Nop"
            return
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

    def compare_6sq(self, dice2):
        check = True
        for i in range(6):
            if self.label[i] == dice2.label[i] :
                continue
            else:
                check = False
                break

        return check
    
    def compare_4rot(self, dice2):
        ok = False
        for i in range(4):
            self.move("CW")
            if self.compare_6sq(dice2) :
                ok =True
                break
        return ok
    
    def compare(self,dice2)
        ok = False
        orderway =("Nop","E","N","E","N","E")

        for s in orderway:
            self.move(s)
            if self.compare_4rot(dice2):
                ok = True
                break
        
        return ok





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

if dice1.compare(dice2) :
    print ("Yes")
else:
    print ("No")

Submission status: Runtime Error

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

    def judge(self, dice):
        if self.data[0] != dice[0]:
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('E')
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('N')
        if self.data[1] != dice[1]:
            for i in range(3):
                self.move('R')
                if self.data[1] == dice[1]:
                    break
        if self.data[2] == dice[2]:
            return 'Yes'
        else:
            return 'No'


dice = Dice(input().split())
hoge = [i for i in input().split()]

print(dice.judge(hoge))

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, data):
        self.data = data
    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]

    def judge(self, dice):
        if self.data[0] != dice[0]:
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('E')
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('N')
        if self.data[1] != dice[1]:
            for i in range(3):
                self.move('R')
                if self.data[1] == dice[1]:
                    break
        for i in range(2,7):
            if self.data[i] != dice[i]:
                return 'No'
        return 'Yes'
            
dice = Dice(input().split())
hoge = [i for i in input().split()]

print(dice.judge(hoge))

Submission status: Runtime Error

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

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]

        return self.data[2]
    def judge(self, dice):
        if self.data[0] != dice[0]:
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('E')
            for i in range(4):
                if self.data[0] == dice[0]:
                    break
                self.move('N')
        if self.data[1] != dice[1]:
            for i in range(3):
                self.move('R')
                if self.data[1] == dice[1]:
                    break
        for i in range(2,7):
            if self.data[i] != dice[i]:
                return 'No'
        return 'Yes'
            
dice = Dice(input().split())
hoge = [i for i in input().split()]

print(dice.judge(hoge))

Submission status: Runtime Error

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

    def __eq__(self, value):
        for i in range(4):
            if self.data[0] == value.data[0]:
                for j in range(4):
                    if self.data == value.data:
                        return True
                    self.move('N')
            self.move('E')
        return False

    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]


    def getTop(self):
        return self.data[0]

    def getRight(self, top, front):
        if self.data[0] != top:
            for i in range(4):
                if self.data[0] == top:
                    break
                self.move('E')
            for i in range(4):
                if self.data[0] == top:
                    break
                self.move('N')

        if self.data[1] != front:
            for i in range(3):
                self.move('R')
                if self.data[1] == front and self.data[0] == top:
                    break
        return self.data[2]

            
dice = Dice(input().split())
hoge = [i for i in input().split()]

print(dice.judge(hoge))

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, data):
        self.data = data
    
    def __eq__(self, value):
        for a in range(0,6,5):
            self.moveTopTo(self.getSortedList()[a])
            value.moveTopTo(value.getSortedList()[a])
            for b in range(4):
                print(self.data, value.data)
                if self.data == value.data:
                    return True
                else:
                    value.move('R')
        return False

    def move(self, direction):
        if direction == 'E':
            self.data[0], self.data[3], self.data[5], self.data[2] = \
                self.data[3], self.data[5], self.data[2], self.data[0]
        elif direction == 'N':
            self.data[0], self.data[4], self.data[5], self.data[1] = \
                self.data[1], self.data[0], self.data[4], self.data[5]
        elif direction == 'S':
            self.data[0], self.data[1], self.data[5], self.data[4] = \
                self.data[4], self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0], self.data[2], self.data[5], self.data[3] = \
                self.data[2], self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[3], self.data[1], self.data[2], self.data[4]
        elif direction == 'L':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[2], self.data[4], self.data[3], self.data[1]

    def moveTopTo(self, target):
        for a in range(4):
            if self.data[0] == target:
                break
            self.move('W')
        if self.data[4] == target:
            self.move('S')
        elif self.data[1] == target:
            self.move('N')
    
    def moveFrontTo(self, target):
        for a in range(4):
            if self.data[1] == target:
                break
            self.move('R')

    def getTop(self):
        return self.data[0]
    
    def getRight(self):
        return self.data[2]

    def getSortedList(self):
        tmp = self.data[:]
        tmp.sort()
        return tmp


from Dice import Dice
a = Dice(input().split())
b = Dice(input().split())
if a == b:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
class Dice:	
	def __init__( self, nums ):
		self.face = nums
	
	def rolltoTopIndex( self, faceindex ):	
		if faceindex == 1:
			self.roll( "N" )
		elif faceindex == 2:
			self.roll( "W" )
		elif faceindex == 3:
			self.roll( "E" )
		elif faceindex == 4:
			self.roll( "S" )
		elif faceindex == 5:
			self.roll( "NN" )
	
	def roll( self, actions ):
		for act in actions:
			t = 0
			if act == "E":
				t =   self.face[0]
				self.face[0] =   self.face[3]
				self.face[3] =   self.face[5]
				self.face[5] =   self.face[2]
				self.face[2] = t
			elif  act == "N":
				t =   self.face[0]
				self.face[0] =   self.face[1]
				self.face[1] =   self.face[5]
				self.face[5] =   self.face[4]
				self.face[4] = t
			elif  act == "S":
				t =  self.face[ 0]
				self.face[0] =  self.face[4]
				self.face[4] =  self.face[5]
				self.face[5] =  self.face[1]
				self.face[1] = t	
			elif  act == "W":
				t =  self.face[0]
				self.face[0] =  self.face[2]
				self.face[2] =  self.face[5]
				self.face[5] =  self.face[3]
				self.face[3] = t	
			elif  act == "M":
				t =  self.face[1]
				self.face[1] =  self.face[2]
				self.face[2] =  self.face[4]
				self.face[4] =  self.face[3]
				self.face[3] = t

diceface = [ int( val ) for val in input( ).split( " " ) ]
dice1 = Dice( diceface )
diceface = [ int( val ) for val in input( ).split( " " ) ]
dice2 = Dice( diceface )


cnt = 0
for i in range( 6 ):
	if dice1.face[0] == dice2.face[i]:
		dice2.rolltoTopIndex( i )
		for j in range( 1, 5 )
			if dice1.face[1] == dice2.face[1]:
				cnt = 0
				for k in range( 6 ):
					if dice1.face[k] == dice2.face[k]:
						cnt += 1
				if cnt == 6
					break
			dice2.roll( "M" )
	if cnt == 6
		break
	dice2.face = diceface


if cnt == 6:
	print( "Yes" )
else:
	print( "No" )

Submission status: Runtime Error

Solution code:
import random
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

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

def same(a, b):
    if ((a.top, a.bottom, a.right, a.left, a.front, a.back) ==
        (b.top, b.bottom, b.right, b.left, b.front, b.back)):
        return True
    else:
        return False

ref = {}
ls1 = map(int, raw_input().split())
ls2 = map(int, raw_input().split())
dice1 = Dice(ls1[0], ls1[1], ls1[2], ls1[3], ls1[4], ls1[5])
dice2 = Dice(ls2[0], ls2[1], ls2[2], ls2[3], ls2[4], ls2[5])
for i in xrange(1000):
    d = "NSEW"[random.randint(0,3)]
    dice1.rot(d)
    if same(dice1, dice2):
        print "Yes"
        break
else:
    print "No"

Submission status: Runtime Error

Solution code:
# coding=utf-8


class Dice(object):

    def __init__(self, list_):
        self.label = list_

    def getLabel(self, i):
        return self.label[i - 1]

    def _rotateS(self):
        self.label = [self.getLabel(i) for i in [5, 1, 3, 4, 6, 2]]

    def _rotateN(self):
        self.label = [self.getLabel(i) for i in [2, 6, 3, 4, 1, 5]]

    def _rotateE(self):
        self.label = [self.getLabel(i) for i in [4, 2, 1, 6, 5, 3]]

    def _rotateW(self):
        self.label = [self.getLabel(i) for i in [3, 2, 6, 1, 5, 4]]

    def _spinPos(self):
        self.label = [self.getLabel(i) for i in [1, 4, 2, 5, 3, 6]]

    def _spinNeg(self):
        self.label = [self.getLabel(i) for i in [1, 3, 5, 2, 4, 6]]

    def rotate(self, rotates):
        for r in rotates:
            if r == 'S':
                self._rotateS()
            elif r == 'N':
                self._rotateN()
            elif r == 'E':
                self._rotateE()
            elif r == 'W':
                self._rotateW()
            elif r == 'T':
                self._spinPos()
            elif r == 'B':
                self._spinNeg()

    def matchTopFront(self, top, front):
        iTop = self.label.index(top) + 1
        topRot = {1: '', 2: 'N', 3: 'W', 4: 'E', 5: 'S', 6: 'SS'}
        self.rotate(topRot[iTop])

        iFront = self.label.index(front) + 1
        frontRot = {2: '', 3: 'B', 4: 'T', 5: 'TT'}
        self.rotate(frontRot[iFront])


def main():
    face1 = map(int, raw_input().split())
    face2 = map(int, raw_input().split())
    if set(face1) != set(face2):
        print 'No'
    else:
        d1 = Dice(face1)
        d2 = Dice(face2)
        d1Top = d1.getLabel(1)
        d1Front = d1.getLabel(2)
        d2.matchTopFront(d1Top, d1Front)
        print 'Yes' if d1.label == d2.label else 'No'

if __name__ == '__main__':
    main()