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:
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

def float_to_str(num):
    return str("{:.10f}".format(num))

def list_input(tp):
    return map(tp, str_input().split())

# # # # # # # # # # # # # # # # # # # # # # # # #

class Dice:
    pip = [0 for i in xrange(6)]

    def __init__(self, arg):
        self.pip = arg

    def rollDir(self, dr):
        nextPip = [0 for i in xrange(6)]
        if dr == "N":
            nextPip[0] = self.pip[1]
            nextPip[1] = self.pip[5]
            nextPip[2] = self.pip[2]
            nextPip[3] = self.pip[3]
            nextPip[4] = self.pip[0]
            nextPip[5] = self.pip[4]
        elif dr == "E":
            nextPip[0] = self.pip[3]
            nextPip[1] = self.pip[1]
            nextPip[2] = self.pip[0]
            nextPip[3] = self.pip[5]
            nextPip[4] = self.pip[4]
            nextPip[5] = self.pip[2]
        self.pip = nextPip

    def roll(self, dr):
        if dr == "N" or dr == "E":
            self.rollDir(dr)
        elif dr == "S":
            self.rollDir("N")
            self.rollDir("N")
            self.rollDir("N")
        elif dr == "W":
            self.rollDir("E")
            self.rollDir("E")
            self.rollDir("E")

    def check(self, a, b):
        while self.pip[0] != a:
            if self.pip[2] != a and self.pip[3] != a:
                self.roll("N")
            else:
                self.roll("N")
                self.roll("W")
                self.roll("S")

        while self.pip[1] != b:
            self.roll("N")
            self.roll("W")
            self.roll("S")
        return self.pip[2]

dice1 = Dice(list_input(int))
dice2 = Dice(list_input(int))

s = set()
for i in xrange(6):
    s.add(dice1.pip[i])
    s.add(dice2.pip[i])

if len(s) != 6 or dice1.pip[2] != dice2.check(dice1.pip[0], dice1.pip[1]):
    print "No"
else:
    print "Yes"

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,pips):
        self.top = pips[0]
        self.south = pips[1]
        self.east = pips[2]
        self.west = pips[3]
        self.north =pips[4]
        self.bottom=pips[5]
    def n(self):
        self.top,self.south,self.bottom,self.north = \
        self.south,self.bottom,self.north,self.top
    def s(self):
        self.top,self.north,self.bottom,self.south = \
        self.north,self.bottom,self.south,self.top
    def e(self):
        self.top,self.west,self.bottom,self.east = \
        self.west,self.bottom,self.east,self.top
    def w(self):
        self.top,self.east,self.bottom,self.west = \
        self.east,self.bottom,self.west,self.top
    def r(self):
        self.north,self.east,self.south,self.west = \
        self.east,self.south,self.west,self.north
    def set(self,t,s):
        for i in range(4):
            if self.top != t:
                if self.east == t or self.west == t:
                    self.e()
                else:
                    self.n()
            else:
                break
        for i in range(4):
            if self.south != s:
                self.r()
            else:
                break
        if(self.top == t and self.south == s):
            return True
        else:
            return False


pips = [int(x) for x in input().split()]
a = Dice(pips)
pips = [int(x) for x in input().split()]
b = Dice(pips)
if (a.set(b.top,b.south)):
    if(a.east == b.east and
       a.west == b.west and
       a.north == b.north and
       a.bottom == b.bottom ):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self, labels):
        self.labels = labels
        self.up = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.down = labels[5]
    def east(self):
        self.up, self.right, self.down, self.left = self.left, self.up, self.right, self.down
        self.update_labels()
    def north(self):
        self.up, self.back, self.down, self.front = self.front, self.up, self.back, self.down
        self.update_labels()
    def south(self):
        self.up, self.front, self.down, self.back = self.back, self.up, self.front, self.down
        self.update_labels()
    def west(self):
        self.up, self.left, self.down, self.right = self.right, self.up, self.left, self.down
        self.update_labels()
    def clockwise(self):
        self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        self.update_labels()
    def counterclockwise(self):
        self.front, self.right, self.back, self.left = self.left, self.front, self.right, self.back
        self.update_labels()
    def set_up(self, up):
        for i in range(6):
            if up == self.up:
                break
            if i % 2:
                self.east()
            else:
                self.north()
    def set_front(self, front):
        while True:
            if front == self.front:
                break
            self.clockwise()
    def update_labels(self):
        self.labels = [self.up, self.front, self.right, self.left, self.back, self.down]

dice_1 = Dice(list(map(int, input().split())))
dice_2 = Dice(list(map(int, input().split())))
if dice_1.up in dice_2.labels:
    dice_2.set_up(dice_1.up)
if dice_1.front in dice_2.labels:
    dice_2.set_front(dice_1.front)
if dice_1.labels == dice_2.labels:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self, labels):
        self.labels = labels
        self.up = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.down = labels[5]
    def east(self):
        self.up, self.right, self.down, self.left = self.left, self.up, self.right, self.down
        self.update_labels()
    def north(self):
        self.up, self.back, self.down, self.front = self.front, self.up, self.back, self.down
        self.update_labels()
    def south(self):
        self.up, self.front, self.down, self.back = self.back, self.up, self.front, self.down
        self.update_labels()
    def west(self):
        self.up, self.left, self.down, self.right = self.right, self.up, self.left, self.down
        self.update_labels()
    def clockwise(self):
        self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        self.update_labels()
    def counterclockwise(self):
        self.front, self.right, self.back, self.left = self.left, self.front, self.right, self.back
        self.update_labels()
    def set_up(self, up):
        for i in range(6):
            if up == self.up:
                break
            if i % 2:
                self.east()
            else:
                self.north()
    def set_front(self, front):
        while True:
            if front == self.front:
                break
            self.clockwise()
    def update_labels(self):
        self.labels = [self.up, self.front, self.right, self.left, self.back, self.down]

dice_1 = Dice(list(map(int, input().split())))
dice_2 = Dice(list(map(int, input().split())))
flag = False
for i in range(6):
    if dice_1.labels == dice_2.labels:
        flag = True
        break
    if i % 2:
        dice_2.east()
    else:
        dice_2.north()
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self, labels):
        self.labels = labels
        self.up = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.down = labels[5]
    def east(self):
        self.up, self.right, self.down, self.left = self.left, self.up, self.right, self.down
        self.update_labels()
    def north(self):
        self.up, self.back, self.down, self.front = self.front, self.up, self.back, self.down
        self.update_labels()
    def south(self):
        self.up, self.front, self.down, self.back = self.back, self.up, self.front, self.down
        self.update_labels()
    def west(self):
        self.up, self.left, self.down, self.right = self.right, self.up, self.left, self.down
        self.update_labels()
    def clockwise(self):
        self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        self.update_labels()
    def counterclockwise(self):
        self.front, self.right, self.back, self.left = self.left, self.front, self.right, self.back
        self.update_labels()
    def set_up(self, up):
        for i in range(6):
            if up == self.up:
                break
            if i % 2:
                self.east()
            else:
                self.north()
    def set_front(self, front):
        while True:
            if front == self.front:
                break
            self.clockwise()
    def update_labels(self):
        self.labels = [self.up, self.front, self.right, self.left, self.back, self.down]

dice_1 = Dice(list(map(int, input().split())))
dice_2 = Dice(list(map(int, input().split())))
flag = False
for i in range(24):
    if dice_1.labels == dice_2.labels:
        flag = True
        break
    if i % 4:
        dice_2.east()
    else:
        dice_2.north()
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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 main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]
    dice = Dice(f)
    labels = []
    for i in range(4):
        dice.north()
        if i != 3:
            labels.append(dice.label)
    for i in range(3):
        dice.west()
        labels.append(dice.label)
    if s in labels:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]
    dice = Dice(f)
    labels = []
    for i in range(4):
        dice.north()
        labels.append(dice.label)
    for i in range(3):
        dice.west()
        if i != 1:
            labels.append(dice.label)
    if s in labels:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 rotate(self):
        self.change([4, 2, 1, 6, 5, 3])

    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')

Submission status: Wrong Answer

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 rotate(self):
        self.change([4, 2, 1, 6, 5, 3])

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

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 rotate(self):
        self.change([4, 2, 1, 6, 5, 3])

    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
                    j += 1
        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: Wrong Answer

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 is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(4):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_west()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

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

Submission status: Wrong Answer

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 roll_roll(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[3],
                      self.faces[4], self.faces[1], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]

    def is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(4):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_west()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

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

Submission status: Wrong Answer

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 roll_roll(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]

    def is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(4):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_roll()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

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

Submission status: Wrong Answer

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

    def roll_roll(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]

    def is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(4):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_roll()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

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

Submission status: Wrong Answer

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

    def roll_roll(self):
        self.faces = (self.faces[0], self.faces[2], self.faces[4],
                      self.faces[1], self.faces[3], self.faces[5])
 
    def number(self, face_id):
        return self.faces[face_id - 1]

    def is_same(self, anotherDice):
        if self.faces == anotherDice.faces:
            return True
        return False
 
dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

flag = False

for i in range(6):
    dice2.roll_north()
    for j in range(4):
        dice2.roll_roll()
        if dice2.is_same(dice1):
            flag = True
            break
    if flag:
        break

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

Submission status: Wrong Answer

Solution code:
import random
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    while True:
        rand=random.randint(1,4)
        if rand==1:
            N()
        elif rand==2:
            E()
        elif rand==3:
            W()
        else:
            S()
        if Dice[0]==Dice2[0]:
            break
    for i in range(3):
        N()
        W()
        S()
        if Dice==Dice2:
            break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    while True:
        if Dice[0]==Dice2[0]:
            break
        if count%2==0:
            N()
        else:
            W()
    for i in range(3):
        N()
        W()
        S()
        if Dice==Dice2:
            break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    while True:
        if Dice[0]==Dice2[0]:
            break
        if count%2==0:
            N()
        else:
            W()
        count+=1
    for i in range(3):
        N()
        W()
        S()
        if Dice==Dice2:
            break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    while True:
        if Dice[0]==Dice2[0]:
            break
        if count%2==0:
            N()
        else:
            W()
        count+=1
    for i in range(4):
        N()
        W()
        S()
        if Dice==Dice2:
            break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    for j in range(6):
        if count%2==0:
            N()
        else:
            W()
        count+=1
        for i in range(4):
            N()
            W()
            S()
            if Dice==Dice2:
                break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    for j in range(12):
        if count%2==0:
            N()
        else:
            W()
        count+=1
        for i in range(4):
            N()
            W()
            S()
            if Dice==Dice2:
                break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

    def roll(self, s):
        for f in s:
            n = self.f[:]
            if f == 'E':
                t = n[0]
                n[0] = n[3]
                n[3] = n[5]
                n[5] = n[2]
                n[2] = t
            elif f == 'W':
                t = n[0]
                n[0] = n[2]
                n[2] = n[5]
                n[5] = n[3]
                n[3] = t
            elif f == 'N':
                t = n[0]
                n[0] = n[1]
                n[1] = n[5]
                n[5] = n[4]
                n[4] = t
            else:
                t = n[0]
                n[0] = n[4]
                n[4] = n[5]
                n[5] = n[1]
                n[1] = t
            self.f = n

    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')

    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

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

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

    def r(self):
        return self.f[2]

    def __eq__ (self, other):
        if other is None or type(self) != type(other): return False
        return self.__dict__ == other.__dict__

d1, d2 = (Dice(list(input().split())) for _ in range(2))
t2 = d1.f.index(d2.top())
d1.to_top(t2)
for _ in range(3):
    if d1 == d2:
        print('Yes')
        sys.exit(0)
    else: d1.side_roll()
print('No')