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

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

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

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

Submission status: Wrong Answer

Solution code:
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
if dice1[1] != dice2[1]:
    for i in range(3):
        rolling('N', dice2)
        if dice1[1] == dice2[1]:
            break
    rolling('E', dice2)
    for i in range(3):
        rolling('N', dice2)
        if dice1[1] == dice2[1]:
            break
if dice1[0] != dice2[0]:
    for i in range(3):
        rolling('E', dice2)
        if dice1[0] == dice2[0]:
            break

if dice1 == dice2:
    print "Yes"
else:
    print "No"

Submission status: Wrong Answer

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

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

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

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
count = 0
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(3):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 4:
            rolling('N', dice2)
            count += 1
        elif 7 > count and count >= 4:
            rolling('E', dice2)
            count += 1
        else:
            print "No"
            break

Submission status: Wrong Answer

Solution code:
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
count = 0
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(3):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 4:
            rolling('N', dice2)
            count += 1
        elif 7 > count and count >= 4:
            if count == 4:
                rolling('E', dice2)
            rolling('N', dice2)
            count += 1
        else:
            print "No"
            break

Submission status: Wrong Answer

Solution code:
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
count = 0
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(3):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 3:
            rolling('N', dice2)
            count += 1
        elif 7 > count and count >= 3:
            if count == 3:
                rolling('E', dice2)
            rolling('N', dice2)
            count += 1
        else:
            print "No"
            break

Submission status: Wrong Answer

Solution code:
dice1 = map(int, raw_input().split())
dice2 = map(int, raw_input().split())
 
def rolling(inst, dice):
    if inst == 'E':
        dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5]
    elif inst == 'W':
        dice[5], dice[3], dice[0], dice[2] = dice[3], dice[0], dice[2], dice[5]
    elif inst == 'N':
        dice[5], dice[4], dice[0], dice[1] = dice[4], dice[0], dice[1], dice[5]
    elif inst == 'S':
        dice[5], dice[1], dice[0], dice[4] = dice[1], dice[0], dice[4], dice[5]
 
count = 0
def dice_matching():
    if dice1[1] == dice2[1]:
        for i in range(3):
            if dice1 == dice2:
                return 1
                break
            rolling('E', dice2)
        return 0
    else:
        return 0

count = 0
while(1):
    if dice_matching() == 1:
        print "Yes"
        break
    else:
        if count < 4:
            rolling('N', dice2)
            count += 1
        elif 8 > count and count >= 4:
            if count == 4:
                rolling('E', dice2)
            rolling('N', dice2)
            count += 1
        else:
            print "No"
            break

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for order1 in 'NNN':
    for order2 in 'EEEE':
        d1.roll(order2)
        print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5])
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    if status == 'yes':
        break
    
if status == 'no':
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for order1 in 'NNN':
    for order2 in 'EEEE':
        d1.roll(order2)
        print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5])
        if d1.dice == d2:
            status = 'yes'
            break
    if status == 'yes':
        break
    
if status == 'no':
    print('No')
elif status == 'yes':
    print('Yes')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for order1 in 'NNN':
    for order2 in 'EEEE':
        d1.roll(order2)
        print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5])
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    if status == 'yes':
        break
    
if status == 'no':
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for order1 in 'NNN':
    for order2 in 'EEEE':
        d1.roll(order2)
        print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5])
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    d1.roll(order1)
    if status == 'yes':
        break
    
if status == 'no':
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for i in range(3):
    for j in range(4):
        d1.roll('E')
        print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5])
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    if status == 'yes':
        break
    d1.roll('N')
if status == 'no':
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for i in range(3):
    for j in range(4):
        d1.roll('E')
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    if status == 'yes':
        break
    d1.roll('N')
if status == 'no':
    print('No')

Submission status: Wrong Answer

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

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

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

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

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

status = 'no'
d1 = Dice(d)
for i in range(4):
    for j in range(4):
        d1.roll('E')
        if d1.dice == d2:
            print('Yes')
            status = 'yes'
            break
    if status == 'yes':
        break
    d1.roll('N')
if status == 'no':
    print('No')

Submission status: Wrong Answer

Solution code:
class Dice(object):
    """Dice Class

    """

    def __init__(self, numbers):
        """

        Args:
            numbers:
        """
        self.numbers_inverse = {numbers[0]: 1, numbers[1]: 2, numbers[2]: 3, numbers[3]: 4, numbers[4]: 5,
                                numbers[5]: 6}
        self.numbers = {1: numbers[0], 2: numbers[1], 3: numbers[2], 4: numbers[3], 5: numbers[4], 6: numbers[5]}

        self.vertical = [self.numbers[1], self.numbers[2], self.numbers[6], self.numbers[5]]
        self.horizontal = [self.numbers[4], self.numbers[1], self.numbers[3], self.numbers[6]]

    def roll_dice(self, str):
        """

        Args:
            str: move direction

        Returns:

        """
        for s in str:
            if s == 'N':
                self.move_north()
            elif s == 'S':
                self.move_south()
            elif s == 'W':
                self.move_west()
            elif s == 'E':
                self.move_east()

    def set_top(self, value):
        """
        Args:
            value: target_value
        """
        counter = 0
        while counter < 4:
            if self.vertical[0] == value:
                self.map_values()
                return
            else:
                self.roll_dice("S")
            counter += 1
        counter = 0
        while counter < 4:
            if self.vertical[0] == value:
                self.map_values()
                return
            else:
                self.roll_dice("W")
            counter += 1

    def set_front(self, value):
        """
        Args:
            value: target value
        """
        counter = 0
        while counter < 4:
            if self.vertical[1] == value:
                self.map_values()
                return
            else:
                self.roll_dice("SWN")
            counter += 1

    def move_south(self):
        """move this dice towered north
        """
        self.vertical = (self.vertical * 2)[3:7]
        self.horizontal[1] = self.vertical[0]
        self.horizontal[3] = self.vertical[2]

    def move_north(self):
        """move this dice towered south
        """
        self.vertical = (self.vertical * 2)[1:5]
        self.horizontal[1] = self.vertical[0]
        self.horizontal[3] = self.vertical[2]

    def move_east(self):
        """move this dice towered east
        """
        self.horizontal = (self.horizontal * 2)[3:7]
        self.vertical[0] = self.horizontal[1]
        self.vertical[2] = self.horizontal[3]

    def move_west(self):
        """move this dice towered west
        """
        self.horizontal = (self.horizontal * 2)[1:5]
        self.vertical[0] = self.horizontal[1]
        self.vertical[2] = self.horizontal[3]

    def map_values(self):
        self.numbers[1] = self.vertical[0]
        self.numbers[2] = self.vertical[1]
        self.numbers[3] = self.horizontal[2]
        self.numbers[4] = self.horizontal[0]
        self.numbers[5] = self.horizontal[3]
        self.numbers[6] = self.vertical[3]

    def get_top(self):
        return self.vertical[0]


dice1 = Dice([int(x) for x in raw_input().split()])
dice2 = Dice([int(x) for x in raw_input().split()])

[top, front] = [dice2.numbers[1],dice2.numbers[2]]
dice1.set_top(top)
dice1.set_front(front)
if dice1.numbers[3] == dice2.numbers[3]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
class Dice(object):
    """Dice Class

    """

    def __init__(self, numbers):
        """

        Args:
            numbers:
        """
        self.numbers_inverse = {numbers[0]: 1, numbers[1]: 2, numbers[2]: 3, numbers[3]: 4, numbers[4]: 5,
                                numbers[5]: 6}
        self.numbers = {1: numbers[0], 2: numbers[1], 3: numbers[2], 4: numbers[3], 5: numbers[4], 6: numbers[5]}

        self.vertical = [self.numbers[1], self.numbers[2], self.numbers[6], self.numbers[5]]
        self.horizontal = [self.numbers[4], self.numbers[1], self.numbers[3], self.numbers[6]]

    def roll_dice(self, str):
        """

        Args:
            str: move direction

        Returns:

        """
        for s in str:
            if s == 'N':
                self.move_north()
            elif s == 'S':
                self.move_south()
            elif s == 'W':
                self.move_west()
            elif s == 'E':
                self.move_east()

    def set_top(self, value):
        """
        Args:
            value: target_value
        """
        counter = 0
        while counter < 4:
            if self.vertical[0] == value:
                self.map_values()
                return
            else:
                self.roll_dice("S")
            counter += 1
        counter = 0
        while counter < 4:
            if self.vertical[0] == value:
                self.map_values()
                return
            else:
                self.roll_dice("W")
            counter += 1

    def set_front(self, value):
        """
        Args:
            value: target value
        """
        counter = 0
        while counter < 4:
            if self.vertical[1] == value:
                self.map_values()
                return
            else:
                self.roll_dice("SWN")
            counter += 1

    def move_south(self):
        """move this dice towered north
        """
        self.vertical = (self.vertical * 2)[3:7]
        self.horizontal[1] = self.vertical[0]
        self.horizontal[3] = self.vertical[2]
        self.map_values()

    def move_north(self):
        """move this dice towered south
        """
        self.vertical = (self.vertical * 2)[1:5]
        self.horizontal[1] = self.vertical[0]
        self.horizontal[3] = self.vertical[2]
        self.map_values()

    def move_east(self):
        """move this dice towered east
        """
        self.horizontal = (self.horizontal * 2)[3:7]
        self.vertical[0] = self.horizontal[1]
        self.vertical[2] = self.horizontal[3]
        self.map_values()

    def move_west(self):
        """move this dice towered west
        """
        self.horizontal = (self.horizontal * 2)[1:5]
        self.vertical[0] = self.horizontal[1]
        self.vertical[2] = self.horizontal[3]
        self.map_values()

    def map_values(self):
        self.numbers[1] = self.vertical[0]
        self.numbers[2] = self.vertical[1]
        self.numbers[3] = self.horizontal[2]
        self.numbers[4] = self.horizontal[0]
        self.numbers[5] = self.vertical[3]
        self.numbers[6] = self.vertical[2]

    def get_top(self):
        return self.vertical[0]


dice1 = Dice([int(x) for x in raw_input().split()])
dice2 = Dice([int(x) for x in raw_input().split()])

flag = False
if dice1.numbers == dice2.numbers:
    flag = True
else:
    for i in xrange(6):
        for j in xrange(4):
            dice1.roll_dice("SWN")
            if dice1.numbers == dice2.numbers:
                flag = True
        dice1.roll_dice("S")

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