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

Solution code:
class Dice:

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

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

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

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

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

    def number(self, face_id):
        return self.faces[face_id - 1]

    def issame(self, other_dice):
        for i in range(4):
            for j in range(4):
                if self.faces == other_dice.faces:
                    return True
                self.rotate()
            self.roll_north()
        for i in range(4):
            for j in range(4):
                if self.faces == other_dice.faces:
                    return True
                self.rotate()
            self.roll_east()
        return False

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

print("Yes" if dice1.issame(dice2) else "No")

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
# for x in xrange(2):
rolls1 = raw_input().split()
rolls2 = raw_input().split()
testpare = (rolls1[0],rolls1[5])
testparerev = (rolls1[5],rolls1[0])
rolls2pare = [(rolls2[0],rolls2[5]),(rolls2[2],rolls2[3]),(rolls2[1],rolls2[4])]
#??????????????¢????????¢??§?????´??????????????????????????????????¢????
#??¨??¨????????¢?????£????????????????????´???????????¢???3????????¨??????????¢????????????????????????????
if testpare in rolls2pare:
    pareps = rolls2pare.index(testpare)
    revflag = False
elif testparerev in rolls2pare:
    pareps = rolls2pare.index(testparerev)
    revflag = True
else:
    pareps = -1
#?¬???????????????¢??\????????¨????????????????????£??????????¢????
#??????????????????????????????
li1 = [rolls1[1],rolls1[2],rolls1[4],rolls1[3]]
# print pareps
if pareps==0:
    if revflag:
        tmp = rolls2[2]
        rolls2[2] = rolls2[3]
        rolls2[3] = tmp
    li2 = [rolls2[1],rolls2[2],rolls2[4],rolls2[3]]
elif pareps==1:
    if revflag:
        tmp = rolls2[1]
        rolls2[1] = rolls2[4]
        rolls2[4] = tmp
        li2 = [rolls2[0],rolls2[1],rolls2[5],rolls2[4]]
elif pareps==2:
    if revflag:
        tmp = rolls2[0]
        rolls2[0] = rolls2[5]
        rolls2[5] = tmp
    li2 = [rolls2[0],rolls2[3],rolls2[5],rolls2[2]]
else:
    matchflag = False
#?????????????????´?¢????
# print li1
# print li2
i=0
j=li2.index(li1[0])
matchflag = True#else??\??£???????????´?????????
for x in xrange(4):
    # print "%s : %s"%(li1[i],li2[j])
    if li1[i]==li2[j]:
        j+=1
        i+=1
    else:
        matchflag =False
        break
    if i>4:
        i=0
    if j>4:
        j=0
if matchflag:
    print "Yes"
else:
    print "No"

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
import sys
rolls1 = raw_input().split()
rolls2 = raw_input().split()
testpare = (rolls1[0],rolls1[5])
testparerev = (rolls1[5],rolls1[0])
rolls2pare = [(rolls2[0],rolls2[5]),(rolls2[2],rolls2[3]),(rolls2[1],rolls2[4])]
#??????????????¢????????¢??§?????´??????????????????????????????????¢????
#??¨??¨????????¢?????£????????????????????´???????????¢???3????????¨??????????¢????????????????????????????
if testpare in rolls2pare:
    pareps = rolls2pare.index(testpare)
    revflag = False
elif testparerev in rolls2pare:
    pareps = rolls2pare.index(testparerev)
    revflag = True
else:
    print "No"
    sys.exit(0)
#?¬???????????????¢??\????????¨????????????????????£??????????¢????
#??????????????????????????????
li1 = [rolls1[1],rolls1[2],rolls1[4],rolls1[3]]
# print pareps
if pareps==0:
    if revflag:
        tmp = rolls2[2]
        rolls2[2] = rolls2[3]
        rolls2[3] = tmp
    li2 = [rolls2[1],rolls2[2],rolls2[4],rolls2[3]]
elif pareps==1:
    if revflag:
        tmp = rolls2[1]
        rolls2[1] = rolls2[4]
        rolls2[4] = tmp
        li2 = [rolls2[0],rolls2[1],rolls2[5],rolls2[4]]
elif pareps==2:
    if revflag:
        tmp = rolls2[0]
        rolls2[0] = rolls2[5]
        rolls2[5] = tmp
    li2 = [rolls2[0],rolls2[3],rolls2[5],rolls2[2]]
else:
    print "No"
    sys.exit(0)
#?????????????????´?¢????
# print li1
# print li2
i=0
j=li2.index(li1[0])
matchflag = True#else??\??£???????????´?????????
for x in xrange(4):
    # print "%s : %s"%(li1[i],li2[j])
    if li1[i]==li2[j]:
        j+=1
        i+=1
    else:
        matchflag =False
        break
    if i>4:
        i=0
    if j>4:
        j=0
if matchflag:
    print "Yes"
else:
    print "No"

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
import sys
rolls1 = raw_input().split()
rolls2 = raw_input().split()
testpare = (rolls1[0],rolls1[5])
testparerev = (rolls1[5],rolls1[0])
rolls2pare = [(rolls2[0],rolls2[5]),(rolls2[2],rolls2[3]),(rolls2[1],rolls2[4])]
#??????????????¢????????¢??§?????´??????????????????????????????????¢????
#??¨??¨????????¢?????£????????????????????´???????????¢???3????????¨??????????¢????????????????????????????
if testpare in rolls2pare:
    pareps = rolls2pare.index(testpare)
    revflag = False
elif testparerev in rolls2pare:
    pareps = rolls2pare.index(testparerev)
    revflag = True
else:
    print "No"
    sys.exit(0)
#?¬???????????????¢??\????????¨????????????????????£??????????¢????
#??????????????????????????????
li1 = [rolls1[1],rolls1[2],rolls1[4],rolls1[3]]
# print pareps
if pareps==0:
    if revflag:
        tmp = rolls2[2]
        rolls2[2] = rolls2[3]
        rolls2[3] = tmp
    li2 = [rolls2[1],rolls2[2],rolls2[4],rolls2[3]]
elif pareps==1:
    if revflag:
        tmp = rolls2[1]
        rolls2[1] = rolls2[4]
        rolls2[4] = tmp
        li2 = [rolls2[0],rolls2[1],rolls2[5],rolls2[4]]
elif pareps==2:
    if revflag:
        tmp = rolls2[0]
        rolls2[0] = rolls2[5]
        rolls2[5] = tmp
    li2 = [rolls2[0],rolls2[3],rolls2[5],rolls2[2]]
else:
    print "No"
    sys.exit(0)
#?????????????????´?¢????
# print li1
# print li2
i=0
j=li2.index(li1[0])
matchflag = True#else??\??£???????????´?????????
for x in xrange(4):
    # print "%s : %s"%(li1[i],li2[j])
    if li1[i]==li2[j]:
        j+=1
        i+=1
    else:
        matchflag =False
        break
    if i>3:
        i=0
    if j>3:
        j=0
if matchflag:
    print "Yes"
else:
    print "No"

Submission status: Runtime Error

Solution code:
#   ?????¢??¨?????¢?????°?????????????????´?????¢?????°???????????????????????°??????

#   ??????????????¢????????????????????????
class Dice:
    def __init__(self):
        self.top = 1
        self.front = 2
        self.right = 3
        self.left = 4
        self.back = 5
        self.bottom = 6
    #   2->1->5->6
    def turnSouth(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self
    #   4->1->3->6
    def turnEast(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self
    #   3->1->4->6
    def turnWest(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self

    #   5->1->2->6
    def turnNorth(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self
    #   2->3->5->4
    def turnRight(self):
        temp = self.front
        self.front = self.right
        self.right = self.back
        self.back = self.left
        self.left = temp
        return self
    #   2->4->5->3
    def turnLeft(self):
        temp = self.front
        self.front = self.left
        self.left = self.back
        self.back = self.right
        self.right = temp
        return self

#   Dice?????????
myDice = Dice()
#   ?????????????????¶????????\???
myDice.top, myDice.front, myDice.right, myDice.left, myDice.back, myDice.bottom = input().split()
#   ???????????°q????¨??????\???????????????
q = int(input())
#   ?????????????????????????????????????????¨??????
#   ??????????±? ?????´??¢ ???????????????????????????(3)
for i in range(0, q):
    #   ????????????????????? ?????¢(1) ?????¢(2)???
    question = list(input())
    question = "".join(question).split()
    #   ?????¢??????????????????????????????
    for j in range(0, 3):
        if question[0] == myDice.top:
            break
        myDice.turnNorth()
    #   ?????¢??????????????????????????????
    for j in range(0, 3):
        if question[0] == myDice.top:
            break
        myDice.turnEast()
    #   ??£??¢???????????????????????¢????????????????????¢
    for j in range(0, 3):
        if question[1] == myDice.front:
            break
        myDice.turnRight()
    print("{0}".format(myDice.right))

Submission status: Runtime Error

Solution code:
#   2???????????????????????????????????????????????????????????°??????

#   ??????????????¢????????????????????????
class Dice:
    def __init__(self):
        self.top = 1
        self.front = 2
        self.right = 3
        self.left = 4
        self.back = 5
        self.bottom = 6
    #   2->1->5->6
    def turnSouth(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self
    #   4->1->3->6
    def turnEast(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self
    #   3->1->4->6
    def turnWest(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self

    #   5->1->2->6
    def turnNorth(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self
    #   2->3->5->4
    def turnRight(self):
        temp = self.front
        self.front = self.right
        self.right = self.back
        self.back = self.left
        self.left = temp
        return self
    #   2->4->5->3
    def turnLeft(self):
        temp = self.front
        self.front = self.left
        self.left = self.back
        self.back = self.right
        self.right = temp
        return self
    def equals(self, Dice):
        if (self.top == Dice.top and self.front == Dice.front and self.bottom == Dice.bottom and
                    self.back == Dice.back and self.right == Dice.right and self.left == Dice.left):
            return True
        else:
            return False

#   Dice?????????
Dice1 = Dice()
Dice2 = Dice()
#   ?????????????????¶????????\???
Dice1.top, Dice1.front, Dice1.right, Dice1.left, Dice1.back, Dice1.bottom = int(input().split())
Dice2.top, Dice2.front, Dice2.right, Dice2.left, Dice2.back, Dice2.bottom = int(input().split())

#   ?????¢??????????????????????????????
for j in range(0, 3):
    if Dice1.top == Dice2.top:
        break
    Dice2.turnNorth()
#   ?????¢??????????????????????????????
for j in range(0, 3):
    if Dice1.top == Dice2.top:
        break
    Dice2.turnEast()
#   ??£??¢???????????????????????¢????????????????????¢
for j in range(0, 3):
    if Dice1.front == Dice2.front:
        break
    Dice2.turnRight()
if Dice1.equals(Dice2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
class Dice():

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

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def change(self, convert):
        num = []
        for i in range(6):
            num.append(self.label[convert[i] - 1])
        self.label = num

    def is_same_dice(self, another_dice):
        for i in range(6):
            if i % 2 == 0:
                self.north()
            else:
                self.west()
            for j in range(4):
                self.rotate()
                if self.label == another_dice:
                    return True
        return False


def main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]

    if Dice(f).is_same_dice(s):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
class Dice:
    def __init__(self, f):
        self.f = f[:]

    def to_top(self, index):
        if index == 1:
            self.roll('N')
        elif index == 2:
            self.roll('W')
        elif index == 3:
            self.roll('E')
        elif index == 4:
            self.roll('S')
        elif index == 5:
            self.roll('NN')
        return self

    def side_roll(self):
        t  = self.f[1]
        self.f[1] = self.f[2]
        self.f[2] = self.f[4]
        self.f[4] = self.f[3]
        self.f[3] = t
        return self

    def all_face(self):
        faces = []
        for i in range(0,6):
            t = Dice(self.f[:])
            faces.append(t.to_top(i).f)
            for j in range(3):
                faces.append(t.side_roll().f)
        return faces

d1, d2 = (Dice(list(input().split())) for _ in range(2))
fs = d1.all_face()
print('Yes' if d2.f in fs else 'No')

Submission status: Runtime Error

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

class Dice():
    def __init__(self, d):
        self.dice = d

    def InsSN(self, one, two, five, six):
        self.dice[0] = one
        self.dice[1] = two
        self.dice[4] = five
        self.dice[5] = six
        
    def InsWE(self, one, three, four, six):
        self.dice[0] = one
        self.dice[2] = three
        self.dice[3] = four
        self.dice[5] = six

    def S(self):
        one = self.dice[4]
        two = self.dice[0]
        five = self.dice[5]
        six = self.dice[1]
        self.InsSN(one, two, five, six)

    def N(self):
        one = self.dice[1]
        two = self.dice[5]
        five = self.dice[0]
        six = self.dice[4]
        self.InsSN(one, two, five, six)
 
    def W(self):
        one = self.dice[2]
        three = self.dice[5]
        four = self.dice[0]
        six = self.dice[3]
        self.InsWE(one, three, four, six)
        
    def E(self):
        one = self.dice[3]
        three = self.dice[0]
        four = self.dice[5]
        six = self.dice[2]
        self.InsWE(one, three, four, six)
        
    def roll(self, order):
        if order == 'S':
            self.S()
        elif order == 'N':
            self.N()
        elif order == 'E':
            self.E()
        elif order == 'W':
            self.W()

status = 'unfinish'
d1 = Dice(d)
for order1 in 'NNN':
    for order2 in 'EEEE':
        d1.roll(order2)
        if d1 == d2:
            print('Yes')
            status = 'finish'

    d1.roll(order)
    if status == 'finish':
        break
if status != 'finish':
    print('No')

Submission status: Runtime Error

Solution code:
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
d1 = {v: k for k, v in enumerate(d1)}
d2 = {v: k for k, v in enumerate(d2)}
boo = True if len(d1) == 6 and len(d2) == 6 else False

if boo:
    x, y = d2[top], d2[front]
    if right == d2[p[x][y]]:
        print("Yes")
    else:
        print("No")

else:
    d1 = [(k, v) for k, v in enumerate(d1)]
    d2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if d1[m][1] != d1[m-1][1]:
            x, y = d1[m][0], d1[m-1][0]
            t1, f1, r1 = d1[m][0], d1[m-1][0], d1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if d2[m][1] != d2[m-1][1]:
            x, y = d2[m][0], d2[m-1][0]
            t2, f2, r2 = d2[m][0], d2[m-1][0], d2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
p = [(-1,2,4,1,3,-1),
     (3,-1,0,5,-1,2),
     (1,5,-1,-1,0,4),
     (4,0,-1,-1,5,1),
     (2,-1,5,0,-1,3),
     (-1,3,1,4,2,-1)]

d1 = list(map(int, input().split()))
top, front, right = d1[0], d1[1], d1[2]
d2 = list(map(int, input().split()))
d1 = {v: k for k, v in enumerate(d1)}
d2 = {v: k for k, v in enumerate(d2)}
boo = True if len(d1) == 6 and len(d2) == 6 else False
if boo:
    x, y = d2[top], d2[front]
    adjacent = {v: k for k, v in d2.items()}
    try:
        if right == adjacent[p[x][y]]:
            print("Yes")
        else:
            print("No")
    except KeyError:
        print("No")

else:
    d1 = [(k, v) for k, v in enumerate(d1)]
    d2 = [(k, v) for k, v in enumerate(d2)]
    for m in range(5, 1, -1):
        if d1[m][1] != d1[m-1][1]:
            x, y = d1[m][0], d1[m-1][0]
            t1, f1, r1 = d1[m][0], d1[m-1][0], d1[p[x][y]][0]
            break
        else:
            t1, f1, r1 = 0, 0, 0
    for m in range(5, 1, -1):
        if d2[m][1] != d2[m-1][1]:
            x, y = d2[m][0], d2[m-1][0]
            t2, f2, r2 = d2[m][0], d2[m-1][0], d2[p[x][y]][0]

    if t2 == r1 and r2 == t1:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

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

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

dice1=dice(d1)
dice2=dice(d2)

if sorted(d1)!=sorted(d2):
	print("No")
else:
	c=["E","W","S","N"]
	import random
	for i in l:
		n=0
		while n<10**5:
			if dice1.d==dice2.d:
				break 
			else:
				dice1.roll(c[random.randint(1,2)])
			n+=1
		if n>10**5:
			print("No")
		else:
			print("Yes")

Submission status: Runtime Error

Solution code:
class Dice:
    index_list_map = [[[-1],[2,3,4,5],[4,1,3,5],[1,4,2,5],[3,2,1,5],[-1]],
                      [[3,2,5,4],[-1],[0,5,3,4],[5,0,2,4],[-1],[2,3,0,4]],
                      [[1,4,5,3],[5,0,4,3],[-1],[-1],[0,5,1,3],[4,1,0,3]],
                      [[4,1,5,2],[0,5,4,2],[-1],[-1],[5,0,1,2],[1,4,0,2]],
                      [[2,3,5,1],[-1],[5,0,3,1],[0,5,2,1],[-1],[3,2,0,1]],
                      [[-1],[3,2,4,0],[1,4,3,0],[4,1,2,0],[2,3,1,0],[-1]]]

    def __init__(self,list):
        self.num = list

    def lookup_east_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][0]]


    def lookup_west_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][1]]

    def lookup_north_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][2]]

    def lookup_down_side(self,u,s):
        index_upside = u
        index_sside = s
        return self.num[self.index_list_map[index_upside][index_sside][3]]

spots1 = map(int,raw_input().split())
spots2 = map(int,raw_input().split())

s2_index_u = [ i for i,x in enumerate(spots2) if x == spots1[0]]
s2_index_s = [ i for i,x in enumerate(spots2) if x == spots1[1]]

combinations_u_s = [ [x,y] for x in s2_index_u for y in s2_index_s if x != y ]

dice2 = Dice(spots2)

for comb in  combinations_u_s :
    e = dice2.lookup_east_side(comb[0],comb[1])
    w = dice2.lookup_west_side(comb[0],comb[1])
    n = dice2.lookup_north_side(comb[0],comb[1])
    d = dice2.lookup_down_side(comb[0],comb[1])

    if e == spots1[2] and w == spots1[3] and n == spots1[4] and d == spots1[5]:
        print "Yes"
        quit()
print "No"

Submission status: Runtime Error

Solution code:
def ch3(t,s,e):
    for j in R:
        if e in j:
            continue
        return(0 if (e == R.index(j)) ^ ((j.index(t) - j.index(s)) %4 == 3) else 1)
        break
R = ((1,2,4,3),(2,0,3,5),(0,1,5,4))
f,g = input().split(), input().split()

t,s,e,w,n,b = map(f.index, g)
print('Yes' if ch3(t,s,e)*ch3(w,n,b) else 'No')

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self,l1,l2,l3,l4,l5,l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.top = 1
        self.front = 2
        self.right = 3

    def get_top(self):
        return eval("self." + 'l' + str(self.top))

    def get_right(self):
        return eval("self." + 'l' + str(self.right))

    def get_front(self):
        return eval("self." + 'l' + str(self.front))

    def rot(self):
        self.front,self.right = self.right,7-self.front

    def move(self, order):
        if order == 'S':
            pretop = self.top
            self.top = 7 - self.front
            self.front = pretop
        elif order == 'E':
            pretop = self.top
            self.top = 7 - self.right
            self.right = pretop


def match_top(dice,target):
    for i in range(4):
        dice.move('S')
        if dice.get_top() == target:
            return dice
    return false


l = list(map(int,input().split()))
d1 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

l = list(map(int,input().split()))
d2 = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

d1_top = d1.get_top()
d1_front = d1.get_front()
d1_right = d1.get_right()
ret = match_top(d2,d1_top)

if ret == False:
    d2.move('E')
    ret = match_top(d2,d1_top)

if ret == False:
    print('No')
else:
    matched = False
    for i in range(4):
        d2.rot()
        if d2.get_front() == d1_front and d2.get_right() == d1_right:
            matched = True
            print ('Yes')
            break
    if not matched:
        print('No')

Submission status: Runtime Error

Solution code:
dice_a = list(map(int,input().split()))
dice_b = list(map(int,input().split()))
dice_a_roll = []


for i in range(6):
    if dice_a[i] == dice_b[0]:
        b_top = i + 1
    if dice_a[i] == dice_b[1]:
        b_front = i + 1


if b_top == 1:
    order=[2,3,5,4,2,3,5]
    for k in range(4):
        if b_front == order[k]:
            spots = [1, order[k], order[k+1], order[k+3], order[k+2], 6]

elif b_top == 2:
    order=[6,3,1,4,6,3,1]
    for k in range(4):
        if b_front == order[k]:
            spots = [2, order[k], order[k+1], order[k+3], order[k+2], 5]

elif b_top == 3:
    order=[2,6,5,1,2,6,5]
    for k in range(4):
        if b_front == order[k]:
            spots = [3, order[k], order[k+1], order[k+3], order[k+2], 4]

elif b_top == 4:
    order=[2,1,5,6,2,1,5]
    for k in range(4):
        if b_front == order[k]:
            spots = [4, order[k], order[k+1], order[k+3], order[k+2], 3]

elif b_top == 5:
    order=[1,3,6,4,1,3,6]
    for k in range(4):
        if b_front == order[k]:
            spots = [5, order[k], order[k+1], order[k+3], order[k+2], 2]

elif b_top == 6:
    order=[2,4,5,3,2,4,5]
    for k in range(4):
        if b_front == order[k]:
            spots = [6, order[k], order[k+1], order[k+3], order[k+2], 1]


for l in spots:
    dice_a_roll.append(dice_a[l-1])


if dice_a_roll == dice_b:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
Dice1 = list(input().split())
Dice2 = list(input().split())
a = list
b = 1

for q in range(3):
    if Dice1[q] == Dice2[q]:
        a[q] = 1
    else :
        a[q] = -1

for q in range(3):
    b = b*a[q]

if b == 1 :
    print("Yes")
elif b == -1 :
    print("No")

Submission status: Runtime Error

Solution code:
import sys
x1=[int(i)for i in input().split()]
x2=[int(i)for i in input().split()]
for i in range(6):
    if x2[i]==x1[0]:
        if x2[5-i]==x1[5]:
            count=i
            break
if x2[count]==x1[0] and x2[5-count]==x1[5]:
    if count==0 or count==5:
        if count==5:
            for i in range(2):
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
    else:
        if count==1 or count==4:
            while x1[0]!=x2[0]:
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
        else:
            while x1[0]!=x2[0]:
                x2[3],x2[0]=x2[0],x2[3]
                x2[5],x2[3]=x2[3],x2[5]
                x2[2],x2[5]=x2[5],x2[2]
    for i in range(4):
        if x2[2]==x1[2] and x2[3]==x1[3] and x2[4]==x1[4] and x2[1]==x1[1] :
            print('Yes')
            break
        else:
            x2[1],x2[2]=x2[2],x2[1]
            x2[2],x2[4]=x2[4],x2[2]
            x2[4],x2[3]=x2[3],x2[4]
        if i==3:
            print('No')
else:
    print("No")

Submission status: Runtime Error

Solution code:
class dice2():
    def __init__(self,men1,men2,men3,men4,men5,men6):
        self.men=[men1,men2,men3,men4,men5,men6]
        
    def find_num_rside(self,top,front):
        t=self.men.index(top)+1
        f=self.men.index(front)+1
        if [t,f] in [[1,2],[2,6],[6,5],[5,1]]:
            return self.men[3-1]#3
        elif  [t,f] in [[5,6],[6,2],[2,1],[1,5]]:
            return self.men[4-1]#4
        elif [t,f] in [[4,2],[2,3],[3,5],[5,4]]:
            return self.men[1-1]#1
        elif  [t,f] in [[5,3],[3,2],[2,4],[4,5]]:
            return self.men[6-1]#6
        elif  [t,f] in [[1,3],[3,6],[6,4],[4,1]]:
            return self.men[5-1]#5
        elif  [t,f] in [[4,6],[6,3],[3,1],[1,4]]:
            return self.men[2-1]#2
        else:
            return "no_match"
        
D1=dice2(*d1)
D2=dice2(*d2)

i=0
while True:
    one=D1.find_num_rside(d2[i], d2[i+1])
    two=D2.find_num_rside(d2[i], d2[i+1])
    if one!=two:
        print("No")
        break
    i+=2
    if i==6:
        print("Yes")
        break

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0245',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g=list(''.join(g)*2)
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 else:
  if i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0245',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g=list(''.join(g)*2)
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0245',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g+=g
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0235',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g+=g
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0235',5:'1324'}[d.index(e[0])]
f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f[2],f[3]=f[3],f[2]2
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g+=g
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
m={0:'1234',1:'5230',2:'1504',3:'1054',4:'0235',5:'1324'}[d.index(e[0])]
#f=[str(e[i])for i in range(1,5)]+[str(e[1])]
f=[str(e[i])for i in range(1,5)]
f+=f
f[2],f[3]=f[3],f[2]
g=[str(d[int(i)])for i in m]
g[2],g[3]=g[3],g[2]
g+=g
for i in range(4):
 if g[g.index(f[i])+1]!=f[i+1]:print('No');break
 elif i==3:print('Yes')

Submission status: Runtime Error

Solution code:
d,e=[list(map(int,input().split()))for _ in range(2)]
e[3],e[4]=e[4],e[3]
t=0
for i in range(6):
 m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}[i]
 f=[d[int(j)]for j in m];f[3],f[4]=f[4],f[3]
 if f[0]==e[0]:
  for j in range(4):
   if f[1:5]*2[j:j+4]==e[1:5]:t=1;break
print(('No','Yes')[t==1])

Submission status: Runtime Error

Solution code:
import random


class Dice(object):
    def __init__(self):
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6

    def __init__(self, faces):
        self.t = faces[0]
        self.s = faces[1]
        self.e = faces[2]
        self.w = faces[3]
        self.n = faces[4]
        self.b = faces[5]

    def roll(self, direct):
        if direct == 0:
            self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
        elif direct == 1:
            self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b
        elif direct == 2:
            self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n

    def is_equal(dice):
        if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:
            return True
        else:
            return False

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

flag = False

for i in range(10000):
    dice2.roll(random.randint(0, 3))
    if dice1.is_equal(dice2):
        flag = True
        break

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