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: Wrong Answer

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
succeed = False
for i in range(3):
    match = True
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            match = False
            break
        else:
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j-1]:
                    order[j] = 2
    if match:
        if order[0] == 2 or order[1] == 2 or order[2] == 2:
            succeed = True
            break
        if z[i][3] == 0 or z[i][3] == 3:
            if sum(order) % 2:
                succeed = True
                break
        if z[i][3] == 1:
            if not sum(order) % 2:
                succeed = True
                break
if succeed:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,t,f,r,l,ba,bo):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.ba = ba
        self.bo = bo
    
    def E(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.r = a
        self.bo = b
        self.l = c
        self.t = d
    
    def N(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.ba = a
        self.bo = b
        self.f = c
        self.t = d
    
    def S(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.f = a
        self.t = b
        self.ba = c
        self.bo = d
    
    def W(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.l = a
        self.t = b
        self.r = c
        self.bo = d

s = input().split(" ")
dice1 = Dice(s[0],s[1],s[2],s[3],s[4],s[5])
s = input().split(" ")
dice2 = Dice(s[0],s[1],s[2],s[3],s[4],s[5])

if dice1.t == dice2.f:
    dice2.N()
elif dice1.t == dice2.r:
    dice2.W()
elif dice1.t == dice2.l:
    dice2.E()
elif dice1.t == dice2.ba:
    dice2.S()
elif dice1.t == dice2.bo:
    dice2.E()
    dice2.E()
for i in range(4):
    if dice1.t == dice2.t and dice1.f == dice2.f and dice1.r == dice2.r and dice1.l == dice2.l and dice1.ba == dice2.ba and dice1.bo == dice2.bo:
        print("Yes")
        break
    dice2.N()
    dice2.E()
    dice2.S()
    if i == 3:
        print("No")

Submission status: Wrong Answer

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

    def math(self, dice_p1, dice_p2):
        dice_t = []
        same = "No"
        for dice_p in self.dice:
            for i in range(6):
                dice_t.append(dice_p1[dice_p[i]])
            if dice_t == dice_p2:
                same = "Yes"
            dice_t = []
        return same

d = Dice()
dice_p1 = [int(dice_p1) for dice_p1 in input().split()]
dice_p2 = [int(dice_p2) for dice_p2 in input().split()]
print(d.math(dice_p1, dice_p2))

Submission status: Wrong Answer

Solution code:
x1=[int(i)for i in input().split()]
y1=[[int(0)for i in range(4)]for i in range(3)]
y1[0][1]=x1[0]
y1[1][1]=x1[1]
y1[1][2]=x1[2]
y1[1][0]=x1[3]
y1[1][3]=x1[4]
y1[2][1]=x1[5]
x2=[int(i)for i in input().split()]
y2=[[int(0)for i in range(4)]for i in range(3)]
y2[0][1]=x2[0]
y2[1][1]=x2[1]
y2[1][2]=x2[2]
y2[1][0]=x2[3]
y2[1][3]=x2[4]
y2[2][1]=x2[5]
for j in range(3):
    if y2[0][1]==y1[0][1]:
        break
    y2[0][1],y2[1][1]=y2[1][1],y2[0][1]
    y2[1][1],y2[2][1]=y2[2][1],y2[1][1]
    y2[2][1],y2[1][3]=y2[1][3],y2[2][1]
        
if y2[0][1]==y1[0][1]:
    for j in range(4):
        if y2[1][1]==y1[1][1]:
            break
        y2[1][1],y2[1][2]=y2[1][2],y2[1][1]
        y2[1][2],y2[1][3]=y2[1][3],y2[1][2]
        y2[1][3],y2[1][0]=y2[1][0],y2[1][3]
else:
    for j in range(4):
        if y2[0][1]==y1[0][1]:
            break
        y2[0][1],y2[1][2]=y2[1][2],y2[0][1]
        y2[1][2],y2[2][1]=y2[2][1],y2[1][2]
        y2[2][1],y2[1][0]=y2[1][0],y2[2][1]
    for j in range(4):
        if y2[1][1]==y1[1][1]:
            break
        y2[1][1],y2[1][2]=y2[1][2],y2[1][1]
        y2[1][2],y2[1][3]=y2[1][3],y2[1][2]
        y2[1][3],y2[1][0]=y2[1][0],y2[1][3]
if y2[1][1]==y1[1][1]:
    if y2[1][0]==y1[1][0] and y2[1][2]==y1[1][2] and y2[1][3]==y1[1][3] and y2[2][1]==y1[2][1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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]:
        count=i
        if x2[5-i]==x1[5]:
            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: Wrong Answer

Solution code:
class dice:
	def __init__(self,data):
		self.faces = data
	
	def turn(self,direction):
		if direction == 'N':
			idx = [1,5,2,3,0,4]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'E':
			idx = [3,1,0,5,4,2]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'W':
			[self.turn('E') for i in range(3)]
		elif direction == 'c':
			self.turn('N')
			self.turn('W')
			self.turn('S')

if __name__ == '__main__':
	data1 = [int(i) for i in input().split()]
	data2 = [int(i) for i in input().split()]
	d1 = dice(data1)
	d2 = dice(data2)
	
	for o in 'NNNEE':
		if d2.faces[0] == d1.faces[0]:
			break
		d2.turn(o)
	for o in 'ccc':
		if d2.faces[1] == d1.faces[1]:
			break
		d2.turn(o)
	
	if d1.faces == d2.faces:
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

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,d2=[list(map(int,input().split())) for i in range(2)] 
     
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: Wrong Answer

Solution code:
d1,d2=[list(map(int,input().split())) for i in range(2)]

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)

test_nums=[[1,2],[4,2],[1,3]]
for i ,j in test_nums:
    one=D1.find_num_rside(D2.men[i-1],D2.men[j-1])
    two=D2.find_num_rside(D2.men[i-1],D2.men[j-1])
    if one==two:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Dice:
    __slots__ = ['n_list', 'pair_list']

    def __init__(self, n_tup):
        self.n_list = list(n_tup)
        self.pair_list = [self.return_dice_round_pair(self.n_list, 2, 3, 5, 4),
                          self.return_dice_round_pair(self.n_list, 1, 4, 6, 3),
                          self.return_dice_round_pair(self.n_list, 1, 2, 6, 5),
                          self.return_dice_round_pair(self.n_list, 1, 5, 6, 2),
                          self.return_dice_round_pair(self.n_list, 1, 3, 6, 4),
                          self.return_dice_round_pair(self.n_list, 2, 4, 5, 3)
                          ]

    @staticmethod
    def roll_switch(n_list, from_idx_list, to_idx_list):
        n_list[from_idx_list[0] - 1], \
        n_list[from_idx_list[1] - 1], \
        n_list[from_idx_list[2] - 1], \
        n_list[from_idx_list[3] - 1] \
            = n_list[to_idx_list[0] - 1], \
              n_list[to_idx_list[1] - 1], \
              n_list[to_idx_list[2] - 1], \
              n_list[to_idx_list[3] - 1]
        return n_list

    def roll(self, direction):
        if direction == "N":
            self.n_list = self.roll_switch(self.n_list, [1, 2, 6, 5], [2, 6, 5, 1])

        elif direction == "E":
            self.n_list = self.roll_switch(self.n_list, [1, 3, 6, 4], [4, 1, 3, 6])

        if direction == "S":
            self.n_list = self.roll_switch(self.n_list, [1, 2, 6, 5], [5, 1, 2, 6])

        if direction == "W":
            self.n_list = self.roll_switch(self.n_list, [1, 3, 6, 4], [3, 6, 4, 1])

    def spin(self):
        self.n_list = self.roll_switch(self.n_list, [2, 3, 5, 4], [3, 5, 4, 2])

    @staticmethod
    def return_dice_round_pair(n_list, a, b, c, d):
        return [(n_list[a - 1], n_list[b - 1]),
                (n_list[b - 1], n_list[c - 1]),
                (n_list[c - 1], n_list[d - 1]),
                (n_list[d - 1], n_list[a - 1])]

    def return_right_num(self, top, forward):
        for i in range(6):
            if (top, forward) in self.pair_list[i]:
                return self.n_list[i]


def comparison_dice(dice_src, dice_tmp):
    # ?????¢???????????????
    for i in range(4):
        dice_tmp.roll("W")
        if dice_tmp.n_list[0] == dice_src.n_list[0]:
            break
    else:
        for j in range(4):
            dice_tmp.roll("N")
            if dice_tmp.n_list[0] == dice_src.n_list[0]:
                break
        else:
            print("No")
            return

    # ?????¢????????????
    if dice_tmp.n_list[5] != dice_src.n_list[5]:
        print("No")
        return

    # ??????4??¢???????????????????????§spin?????????
    for k in range(4):
        dice_tmp.spin()
        if dice_tmp.n_list == dice_src.n_list:
            print("Yes")
            return
    else:
        print("No")
        return


dice_src = Dice([int(x) for x in input().split()])
dice_tmp = Dice([int(x) for x in input().split()])
comparison_dice(dice_src, dice_tmp)

Submission status: Wrong Answer

Solution code:
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    a, b = die1[:2]
    ans = True
    if die2[0] == a:
        pass
    elif die2[1] == a:
        die2 = roll(die2, "N")
    elif die2[2] == a:
        die2 = roll(die2, "W")
    elif die2[3] == a:
        die2 = roll(die2, "E")
    elif die2[4] == a:
        die2 = roll(die2, "S")
    elif die2[5] == a:
        die2 = roll(roll(die2, "E"), "E")
    else:
        ans = False
    for i in range(4):
        if die2[1] == b:
            break
        die2 = roll(die2, "R")
    for i in range(6):
        if die1[i] != die2[i]:
            ans = False
    return ans

die1 = list(map(int, input().split()))
die2 = list(map(int, input().split()))
if checkdice(die1, die2) is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    ans = "No"
    for d in "RRRNRRRNRRRSRRRSRRRNRRR":
        if die1 == die2:
            ans = "Yes"
            break
        die2 = roll(die2, d)
    return ans

die1 = list(map(int, input().split()))
die2 = list(map(int, input().split()))
print(checkdice(die1, die2))

Submission status: Wrong Answer

Solution code:
# your code goes here
#dice3
def si(n1,n2):
    if n1==1:
        if n2==2:
            return 3
        elif n2==3:
            return 5
        elif n2==4:
            return 2
        else:
            return 4
    elif n1==2:
        if n2==1:
            return 4
        elif n2==3:
            return 1
        elif n2==4:
            return 6
        else:
            return 3
    elif n1==3:
        if n2==2:
            return 6
        elif n2==5:
            return 1
        elif n2==1:
            return 2
        else:
            return 5
    elif n1==4:
        if n2==1:
            return 5
        elif n2==2:
            return 1
        elif n2==5:
            return 6
        else:
            return 2
    elif n1==5:
        if n2==1:
            return 3
        elif n2==3:
            return 6
        elif n2==4:
            return 1
        else:
            return 4
    elif n1==6:
        if n2==3:
            return 2
        elif n2==2:
            return 4
        elif n2==5:
            return 3
        else:
            return 5
def r(D,s):
    if s==1:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==4:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==2:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==5:
        D=r(r(D,1),1)
    return D
C=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
i=0
while i<6 and C[0]!=D[i]:
    i+=1
if i>5 or C[5]!=D[5-i]:
    p="No"
else:
    D=r(D,i)
    i=0
    while i<5 and D[i]!=C[1]:
        i+=1
    if i>5 or C[4]!=D[5-i]:
        p="No"
    else:
        t=si(1,i+1)
        if C[2]!=D[t-1] or C[3]!=D[6-t]:
            p="No"
        else:
            p="Yes"
print(p)

Submission status: Wrong Answer

Solution code:
#dice3
def r(D,s):
    if s==0:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==2:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==1:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==4:
        D=r(r(D,1),1)
    return D
def ch(C,D):
    k=0
    while k<6 and C[k]==D[k]:
        k+=1
    if k==6:
        return 1
    else:
        return 0
C=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
nd=0
if ch(C,D)==1:
    nd=1
i=0
while i<4 and nd==0:
    D=r(D,i)
    j=i+1
    j%=4
    k=0
    while k<3 and nd==0:
        D=r(D,j)
        if ch(C,D)==1:
            nd=1
        k+=1
    D=r(D,j)
    m=i+2
    m//=4
    D=r(D,m)
    i+=1
i=0
while nd==0 and i<4:
    D=r(r(D,i),i)
    if ch(C,D)==1:
        nd=1
    D=r(r(D,i),i)
    i+=1
if nd==1:
    p="Yes"
else:
    p="No"
print(p)

Submission status: Wrong Answer

Solution code:
#dice3
def r(D,s):
    if s==0:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==2:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==1:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==4:
        D=r(r(D,1),1)
    return D
def ch(C,D):
    k=0
    while k<6 and C[k]==D[k]:
        k+=1
    if k==6:
        return 1
    else:
        return 0
C=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
nd=0
if ch(C,D)==1:
    nd=1
i=0
while i<4 and nd==0:
    D=r(D,i)
    j=i+1
    j%=4
    k=0
 #   if i==0:
    #    print(D)
    while k<3 and nd==0:
        D=r(D,j)
        if ch(C,D)==1:
            nd=1
        k+=1
  #      if i==0:
        #    print(D)
    D=r(D,j)
 #   if i==0:
   #     print(D)
    m=i+2
    m%=4
 #   if i==0:
    #    print(m)    
    D=r(D,m)
 #   if i==0:
 #       print(D)
    i+=1
i=0
while nd==0 and i<4:
    D=r(r(D,i),i)
    if ch(C,D)==1:
        nd=1
    D=r(r(D,i),i)
    i+=1
if nd==1:
    p="Yes"
else:
    p="No"
print(p)

Submission status: Wrong Answer

Solution code:
#dice3
def r(D,s):
    if s==0:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==2:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==1:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==4:
        D=r(r(D,1),1)
    return D
def ch(C,D):
    k=0
    while k<6 and C[k]==D[k]:
        k+=1
    if k==6:
        return 1
    else:
        return 0
C=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
nd=0
if ch(C,D)==1:
    nd=1
i=0
while i<4 and nd==0:
    D=r(D,i)
    j=i+1
    j%=4
    k=0
 #   if i==0:
    #    print(D)
    while k<3 and nd==0:
        D=r(D,j)
        if ch(C,D)==1:
            nd=1
        k+=1
  #      if i==0:
        #    print(D)
    D=r(D,j)
 #   if i==0:
   #     print(D)
    m=i+2
    m%=4
 #   if i==0:
    #    print(m)    
    D=r(D,m)
 #   if i==0:
 #       print(D)
    i+=1
i=0
while nd==0 and i<3:
    D=r(D,0)
    D=r(D,1)
    D=r(D,0)
    if ch(C,D)==1:
        nd=1
    D=r(r(D,0),0)
    if ch(C,D)==1:
        nd=1
    i+=1
if nd==1:
    p="Yes"
else:
    p="No"
print(p)

Submission status: Wrong Answer

Solution code:
#dice3
def r(D,s):
    if s==0:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==2:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==1:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==4:
        D=r(r(D,1),1)
    return D
def ch(C,D):
    k=0
    while k<6 and C[k]==D[k]:
        k+=1
    if k==6:
        return 1
    else:
        return 0
C=[int(i) for i in input().split()]
D=[int(i) for i in input().split()]
nd=0
if ch(C,D)==1:
    nd=1
i=0
while i<4 and nd==0:
    D=r(D,i)
    j=i+1
    j%=4
    k=0
    if ch(C,D)==1:
        nd=1
 #   if i==0:
    #    print(D)
    while k<3 and nd==0:
        D=r(D,j)
        if ch(C,D)==1:
            nd=1
        k+=1
  #      if i==0:
        #    print(D)
    D=r(D,j)
 #   if i==0:
   #     print(D)
    m=i+2
    m%=4
 #   if i==0:
    #    print(m)    
    D=r(D,m)
 #   if i==0:
 #       print(D)
    i+=1
i=0
while nd==0 and i<3:
    D=r(D,0)
    D=r(D,1)
    D=r(D,0)
    if ch(C,D)==1:
        nd=1
    D=r(r(D,0),0)
    if ch(C,D)==1:
        nd=1
    i+=1
if nd==1:
    p="Yes"
else:
    p="No"
print(p)

Submission status: Wrong Answer

Solution code:
# Aizu Problem ITP_1_11_C: Dice III
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def do_roll(dice, roll):
    d1, d2, d3, d4, d5, d6 = dice
    if roll == 'E':
        return [d4, d2, d1, d6, d5, d3]
    elif roll == 'W':
        return [d3, d2, d6, d1, d5, d4]
    elif roll == 'N':
        return [d2, d6, d3, d4, d1, d5]
    elif roll == 'S':
        return [d5, d1, d3, d4, d6, d2]
    else:
        assert False, "We should never reach this point!"
    

right_pos = {(1, 2): 3, (1, 4): 2, (1, 5): 4, (1, 3): 5,
             (2, 3): 1, (2, 1): 4, (2, 4): 6, (2, 6): 3,
             (3, 1): 2, (3, 2): 6, (3, 6): 5, (3, 5): 1,
             (4, 1): 5, (4, 2): 1, (4, 6): 2, (4, 5): 6,
             (5, 1): 3, (5, 4): 1, (5, 6): 4, (5, 3): 6,
             (6, 2): 4, (6, 3): 2, (6, 5): 3, (6, 4): 5}

def check_dice(dice1, dice2):
    """
p_top = dice.index(top) + 1
    p_front = dice.index(front)  + 1
    return dice[right_pos[(p_top, p_front)] - 1]
    """
    for k in range(4):
        dice = dice2[:]
        do_roll(dice, 'S')
        if dice == dice1:
            return True
        for j in range(4):
            dice = do_roll(dice, 'E')
            if dice == dice1:
                return True
    return False

    
dice1 = [int(_) for _ in input().split()]
dice2 = [int(_) for _ in input().split()]
print("Yes" if check_dice(dice1, dice2) else "No")

Submission status: Wrong Answer

Solution code:
# Aizu Problem ITP_1_11_C: Dice III
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def do_roll(dice, roll):
    d1, d2, d3, d4, d5, d6 = dice
    if roll == 'E':
        return [d4, d2, d1, d6, d5, d3]
    elif roll == 'W':
        return [d3, d2, d6, d1, d5, d4]
    elif roll == 'N':
        return [d2, d6, d3, d4, d1, d5]
    elif roll == 'S':
        return [d5, d1, d3, d4, d6, d2]
    else:
        assert False, "We should never reach this point!"
    

right_pos = {(1, 2): 3, (1, 4): 2, (1, 5): 4, (1, 3): 5,
             (2, 3): 1, (2, 1): 4, (2, 4): 6, (2, 6): 3,
             (3, 1): 2, (3, 2): 6, (3, 6): 5, (3, 5): 1,
             (4, 1): 5, (4, 2): 1, (4, 6): 2, (4, 5): 6,
             (5, 1): 3, (5, 4): 1, (5, 6): 4, (5, 3): 6,
             (6, 2): 4, (6, 3): 2, (6, 5): 3, (6, 4): 5}

def check_dice(dice1, dice2):
    """
    p_top = dice.index(top) + 1
    p_front = dice.index(front)  + 1
    return dice[right_pos[(p_top, p_front)] - 1]
    """
    dice = dice2[:]
    for j in range(4):
        dice = do_roll(dice, 'E')
        if dice == dice1:
            return True
    for direction in ['S', 'N']:
        dice = do_roll(dice2[:], direction)
        for j in range(4):
            dice = do_roll(dice, 'E')
            if dice == dice1:
                return True
    return False

    
dice1 = [int(_) for _ in input().split()]
dice2 = [int(_) for _ in input().split()]
print("Yes" if check_dice(dice1, dice2) else "No")

Submission status: Wrong Answer

Solution code:
# Aizu Problem ITP_1_11_C: Dice III
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")


def do_roll(dice, roll):
    d1, d2, d3, d4, d5, d6 = dice
    if roll == 'E':
        return [d4, d2, d1, d6, d5, d3]
    elif roll == 'W':
        return [d3, d2, d6, d1, d5, d4]
    elif roll == 'N':
        return [d2, d6, d3, d4, d1, d5]
    elif roll == 'S':
        return [d5, d1, d3, d4, d6, d2]
    else:
        assert False, "We should never reach this point!"
    

right_pos = {(1, 2): 3, (1, 4): 2, (1, 5): 4, (1, 3): 5,
             (2, 3): 1, (2, 1): 4, (2, 4): 6, (2, 6): 3,
             (3, 1): 2, (3, 2): 6, (3, 6): 5, (3, 5): 1,
             (4, 1): 5, (4, 2): 1, (4, 6): 2, (4, 5): 6,
             (5, 1): 3, (5, 4): 1, (5, 6): 4, (5, 3): 6,
             (6, 2): 4, (6, 3): 2, (6, 5): 3, (6, 4): 5}

def check_dice(dice1, dice2):
    """
    p_top = dice.index(top) + 1
    p_front = dice.index(front)  + 1
    return dice[right_pos[(p_top, p_front)] - 1]
    """
    dice = dice2[:]
    for j in range(4):
        dice = do_roll(dice, 'E')
        if dice == dice1:
            return True
    for direction in ['S', 'N']:
        dice = do_roll(dice2[:], direction)
        for j in range(4):
            dice = do_roll(dice, 'E')
            if dice == dice1:
                return True
    dice = do_roll(do_roll(dice2[:], 'S'), 'S')
    for j in range(4):
        dice = do_roll(dice, 'E')
        if dice == dice1:
            return True
    return False

    
dice1 = [int(_) for _ in input().split()]
dice2 = [int(_) for _ in input().split()]
print("Yes" if check_dice(dice1, dice2) else "No")

Submission status: Wrong Answer

Solution code:
class Dice():
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def get_top(self):
        return self.top

    def rotate_north(self):
        self.top,self.south,self.north,self.bottom = self.south,self.bottom,self.top,self.north
    
    def rotate_south(self):
        self.top,self.south,self.north,self.bottom = self.north,self.top,self.bottom,self.south

    def rotate_west(self):
        self.top,self.west,self.bottom,self.east = self.east,self.top,self.west,self.bottom

    def rotate_east(self):
        self.top,self.west,self.bottom,self.east = self.west,self.bottom,self.east,self.top

    def rotate_horizon(self):
        self.south,self.east,self.north,self.west = self.west,self.south,self.east,self.north

    def get_east(self):
        return self.east
        
dice1 = Dice(list(map(int,input().split())))
dice2 = Dice(list(map(int,input().split())))

h=""

for i in range(4):
    dice2.rotate_west()
    if dice1.top == dice2.top:
        for _ in range(4):
            dice2.rotate_horizon()
            if dice1.south == dice2.south:
                if dice1.east == dice2.east:
                    h = "Yes"
for _ in range(4):
    dice2.rotate_north()
    if dice1.top == dice2.top:
        for m in range(4):
            dice2.rotate_horizon()
            if dice1.south == dice2.south:
                if dice1.east == dice2.east:
                    h = "Yes"
if h:
    print(h)
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

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

f=False
for i in range(4):
    d2.roll('N')
    f=f or (d1.get()==d2.get())
for i in range(4):
    d2.roll('W')
    f=f or (d1.get()==d2.get())
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

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

f=False
for _ in range(4):
    d2.roll('N')
    for _ in range(4):
        d2.roll('W')
        print(d2.get())
        f = f or (d1.get() == d2.get())
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

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

f=False
for _ in range(4):
    d2.roll('N')
    for _ in range(4):
        d2.roll('W')
#        print(d2.get())
        f = f or (d1.get() == d2.get())
print('Yes' if f else 'No')