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:
class Dice:
    def __init__(self, data):
        self.data = data
    def move(self, direction):
        if direction == 'E':
            self.data[0],self.data[3], self.data[5], self.data[2] = \
                self.data[3],self.data[5], self.data[2], self.data[0] 
        elif direction == 'N':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[1],self.data[5], self.data[4], self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1], self.data[5], self.data[4] = \
                self.data[4],self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2], self.data[5], self.data[3] = \
                self.data[2],self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1],self.data[2], self.data[4], self.data[3] = \
                self.data[2],self.data[4], self.data[3], self.data[1]

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


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

print(dice.judge(hoge))

Submission status: Wrong Answer

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

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

print(dice.judge(hoge))

Submission status: Wrong Answer

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

    def equalTo(self, comparison):
        return self.data[0] == comparison.data[5] and \
                self.data[1] == comparison.data[1] and \
                self.data[2] == comparison.data[3] and \
                self.data[4] == comparison.data[4]

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

if dice1.equalTo(dice2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

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

print(dice.judge(hoge))

Submission status: Wrong Answer

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

    def equalTo(self, comparison):
        return self.data == comparison.data or \
                self.data[0] == comparison.data[5] and \
                self.data[1] == comparison.data[1] and \
                self.data[2] == comparison.data[3] and \
                self.data[4] == comparison.data[4]

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

if dice1.equalTo(dice2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

    def equalTo(self, comparison):
        return self.data == comparison.data or \
                (self.data[0] == comparison.data[5] and \
                self.data[2] == comparison.data[3])

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

if dice1.equalTo(dice2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

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

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

a = Dice(input().split())
b = Dice(input().split())
a.moveTopTo(a.getSortedList()[0])
a.moveFrontTo(a.getSortedList()[1])
b.moveTopTo(a.getSortedList()[0])
b.moveFrontTo(a.getSortedList()[1])

if a == b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

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


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

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

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

a = Dice(input().split())
b = Dice(input().split())

if a == b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

    def __eq__(self, comparison):
        return self.data == comparison.data or \
                (self.data[0] == comparison.data[5] and \
                self.data[2] == comparison.data[3] and \
                (self.data[1] == comparison.data[1] or \
                self.data[4] == comparison.data[4]) and \
                self.data[1] == comparison.data[4])

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

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

Submission status: Wrong Answer

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

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

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

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

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


a = Dice(input().split())
b = Dice(input().split())

if a == b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

a = Dice(input().split())
b = Dice(input().split())

if a == b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

    def __eq__(self, comparison):
        return self.data == comparison.data or \
                (self.data[0] == comparison.data[5] and \
                (self.data[1] == comparison.data[1] or \
                self.data[4] == comparison.data[4]) and \
                self.data[2] == comparison.data[3] and \
                self.data[3] == comparison.data[2])
 
dice1 = Dice(input().split())
dice2 = Dice(input().split())

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

Submission status: Wrong Answer

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

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

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

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

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


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

Submission status: Wrong Answer

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

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

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

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

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


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

Submission status: Wrong Answer

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

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


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

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

    def moveTopTo(self, target):
        for i in range(4):
            if self.data[0] == target:
                break
            self.move('W')

            if self.data[1] == target:
                self.move('S')
            elif self.data[4] == target:
                self.move('N')

    def moveFrontTo(self, target):
        for i in range(4):
            if self.data[1] == target:
                break
            self.move('LEFT')

    def __eq__(self, comparison):
        comparison.moveTopTo(self.data[0])

        if self.data == comparison.data:
            return True

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

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

Submission status: Wrong Answer

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

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


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

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

    def moveTopTo(self, target):
        for i in range(4):
            if self.data[0] == target:
                break
            self.move('W')

            if self.data[1] == target:
                self.move('S')
            elif self.data[4] == target:
                self.move('N')

    def moveFrontTo(self, target):
        for i in range(4):
            if self.data[1] == target:
                break
            self.move('LEFT')

    def __eq__(self, comparison):
        self.moveTopTo(comparison.data[0])

        for i in range(4):
            if self.data == comparison.data:
                return True
            else:
                self.move('N')

        return False

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

from random import *
import copy

def command(hougaku, label):
    temp = {}
    temp = copy.deepcopy(label)
    if(hougaku == 'E'):
        label[1] = temp[4]
        label[3] = temp[1]
        label[4] = temp[6]
        label[6] = temp[3]
    elif(hougaku == 'W'):
        label[1] = temp[3]
        label[3] = temp[6]
        label[4] = temp[1]
        label[6] = temp[4]
    elif(hougaku == 'N'):
        label[1] = temp[2]
        label[2] = temp[6]
        label[5] = temp[1]
        label[6] = temp[5]
    elif(hougaku == 'S'):
        label[1] = temp[5]
        label[2] = temp[1]
        label[5] = temp[6]
        label[6] = temp[2]

if __name__=="__main__":
    label1 = {}
    label2 = {}
    n1 = map(int, raw_input().split())
    n2 = map(int, raw_input().split())
    for i in range(6):
        label1[i+1] = n1[i]
        label2[i+1] = n2[i]
    #print label1
    #print label2
    count = 0
    flag = 0
    while True:
        if(label1 == label2):
            flag = 1
            break
        x = random()
        if(x < 0.25):
            print 'E'
            command('E', label1)
        elif(x < 0.50):
            print 'W'
            command('W', label1)
        elif(x < 0.75):
            print 'N'
            command('N', label1)
        else:
            print 'S'
            command('S', label1)
        count += 1
        #print label1
        if(count > 1000):
            break
    if(flag == 1):
        print 'Yes'
    else:
        print 'No'

Submission status: Wrong Answer

Solution code:
#coding:utf-8
#1_11_C 2015.4.20
class Dice:
    def __init__(self,ary):
        self.top , self.south , self.east , self.west , self.north ,self.bottom = ary

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

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

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

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

for i in range(3):
    if dice1.top == dice2.top or dice1.south == dice2.south:
        break
    dice1.roll_n()

for j in range(3):
    if dice1.top == dice2.top and dice1.south == dice2.south:
        break

    if dice1.top == dice2.top:
        dice1.twist()
    elif dice1.south == dice2.south:
        dice1.roll_e()

if dice1.top == dice2.top and dice1.north == dice2.north and dice1.south == dice2.south and dice1.east == dice2.east and dice1.west == dice2.west and dice1.bottom == dice2.bottom:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#coding:utf-8
#1_11_C 2015.4.20
class Dice:
    def __init__(self,ary):
        self.top , self.south , self.east , self.west , self.north ,self.bottom = ary

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

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

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

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

for i in range(4):
    if dice1.top == dice2.top or dice1.south == dice2.south:
        break
    dice1.roll_n()

for j in range(4):
    if dice1.top == dice2.top and dice1.south == dice2.south:
        break

    if dice1.top == dice2.top:
        dice1.twist()
    elif dice1.south == dice2.south:
        dice1.roll_e()

if dice1.top == dice2.top and dice1.north == dice2.north and dice1.south == dice2.south and dice1.east == dice2.east and dice1.west == dice2.west and dice1.bottom == dice2.bottom:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#coding:utf-8
#1_11_C 2015.4.20
class Dice:
    def __init__(self,ary):
        self.top , self.south , self.east , self.west , self.north ,self.bottom = ary

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

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

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

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

for i in range(4):
    if dice1.top == dice2.top or dice1.south == dice2.south:
        break
    dice1.roll_n()

for j in range(4):
    if dice1.top == dice2.top and dice1.south == dice2.south:
        break
    elif dice1.top == dice2.top:
        dice1.twist()
    elif dice1.south == dice2.south:
        dice1.roll_e()

if dice1.top == dice2.top and dice1.north == dice2.north and dice1.south == dice2.south and dice1.east == dice2.east and dice1.west == dice2.west and dice1.bottom == dice2.bottom:
    print('Yes')
else:
    print('No')