Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice I

  Write a program to simulate rolling a dice, which can be constructed by the following net.

  As shown in the figures, each face is identified by a different label from 1 to 6.

  Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.

Input

  In the first line, six integers assigned to faces are given in ascending order of their corresponding labels.

  In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.

Output

  Print the integer which appears on the top face after the simulation.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

$0 \leq $ the length of the command $\leq 100$

Sample Input 1

1 2 4 8 16 32
SE

Sample Output 1

8

You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.

Sample Input 2

1 2 4 8 16 32
EESWN

Sample Output 2

32



Sample input:
1 2 4 8 16 32
SE


Sample output:
8

Submission status: Wrong Answer

Solution code:
class Dice():

    def __init__(self, *n):
       self.rolls = n

    def spin(self, order):
        if order == "N":
            self.rolls = [
                self.rolls[1],
                self.rolls[5],
                self.rolls[2],
                self.rolls[3],
                self.rolls[4],
                self.rolls[0]
            ]
        if order == "E":
            self.rolls = [
                self.rolls[3],
                self.rolls[1],
                self.rolls[0],
                self.rolls[5],
                self.rolls[4],
                self.rolls[2]
            ]
        if order == "S":
            self.rolls = [
                self.rolls[4],
                self.rolls[0],
                self.rolls[2],
                self.rolls[3],
                self.rolls[5],
                self.rolls[1]
            ]
        if order == "W":
            self.rolls = [
                self.rolls[2],
                self.rolls[1],
                self.rolls[5],
                self.rolls[0],
                self.rolls[4],
                self.rolls[3]
            ]
        return self.rolls[0]


d = Dice(*[int(i) for i in input().split()])
for order in list(input()):
    l = d.spin(order)
print(l)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
S = list(input())
i = 0
number1 = a
number2 = b
number3 = c
number4 = d
number5 = e
number6 = f

while i < len(S) :
    if S[i] == "N" :
        number1 = b
        number2 = f
        number3 = c
        number4 = d
        number5 = a
        number6 = e
    elif S[i] == "S" :
        number1 = e
        number2 = a
        number3 = c
        number4 = d
        number5 = f
        number6 = b
    elif S[i] == "E" :
        number1 = d
        number2 = b
        number3 = a
        number4 = f
        number5 = e
        number6 = c
    elif S[i] == "W" :
        number1 = c
        number2 = a
        number3 = f
        number4 = a
        number5 = f
        number6 = d
    a = number1
    b = number2
    c = number3
    d = number4
    e = number5
    f = number6
    i = i + 1
print(number1)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e, f = map(int, input().split())
S = list(input())
i = 0
number1 = a
number2 = b
number3 = c
number4 = d
number5 = e
number6 = f

while i < len(S) :
    if S[i] == "N" :
        number1 = b
        number2 = f
        number3 = c
        number4 = d
        number5 = a
        number6 = e
    elif S[i] == "S" :
        number1 = e
        number2 = a
        number3 = c
        number4 = d
        number5 = f
        number6 = b
    elif S[i] == "E" :
        number1 = d
        number2 = b
        number3 = a
        number4 = f
        number5 = e
        number6 = c
    elif S[i] == "W" :
        number1 = c
        number2 = b
        number3 = f
        number4 = a
        number5 = f
        number6 = d
    a = number1
    b = number2
    c = number3
    d = number4
    e = number5
    f = number6
    i = i + 1
print(number1)

Submission status: Wrong Answer

Solution code:
dice = input().split()
direction = list(input())
dice2 = []
for i in range(len(direction)):
    dice2 = dice
    print(dice2)
    if direction[i] == 'E':
        dice = [dice2[3],dice2[1],dice2[0],dice2[5],dice2[4],dice2[2]]
        print(dice)
    elif direction[i] == 'N':
        dice = [dice2[1],dice2[5],dice2[2],dice2[3],dice2[0],dice2[4]]
        print(dice)
    elif direction[i] == 'S':
        dice = [dice2[4],dice2[0],dice2[2],dice2[3],dice2[5],dice2[1]]
        print(dice)
    else:
        dice = [dice2[2],dice2[1],dice2[5],dice2[0],dice2[4],dice2[3]]
        print(dice)
print('{0}'.format(dice[0]))

Submission status: Wrong Answer

Solution code:
dice = input().split()
direction = list(input())
dice2 = []
for i in range(len(direction)):
    dice2 = dice
    print(dice2)
    if direction[i] == 'E':
        dice = [dice2[3],dice2[1],dice2[0],dice2[5],dice2[4],dice2[2]]
        print(dice)
    elif direction[i] == 'N':
        dice = [dice2[1],dice2[5],dice2[2],dice2[3],dice2[0],dice2[4]]
        print(dice)
    elif direction[i] == 'S':
        dice = [dice2[4],dice2[0],dice2[2],dice2[3],dice2[5],dice2[1]]
        print(dice)
    else:
        dice = [dice2[2],dice2[1],dice2[5],dice2[0],dice2[4],dice2[3]]
        print(dice)
print('{0}'.format(int(dice[0])))

Submission status: Wrong Answer

Solution code:
# coding:utf-8
class Dice:
    def __init__(self):
        self.top_label = 1
        self.N = 1; self.W = 2; self.E = 3; self.S = 4
        self.all_label = [0 for i in range(6)]
        self.index = {}
        self.array = [[2,3,4,5],[6,3,4,1],[6,5,2,1],[6,2,5,1],[6,3,4,1],[5,3,4,2]]
    def set_label(self,label):
        for i in range(6):
            self.all_label[i] = label[i]
    def calculate(self): 
        for i in range(6):
            for j in range(4):
                self.array[i][j] = self.all_label[self.array[i][j] - 1]
        for i in range(6):
            self.index[self.all_label[i]] = i
    def dicing(self,direction):
        d = 0
        for i in direction:
            if i == 'N':
                d = self.N - 1
            elif i == 'W':
                d = self.W - 1
            elif i == 'E':
                d = self.E - 1
            elif i == 'S':
                d = self.S - 1
            self.top_label = self.array[self.index[self.top_label]][d]
        return self.top_label

dice = Dice()
dice.set_label(map(int, raw_input().split())) # 1 2 4 8 16 32
dice.calculate()
direction = list(raw_input()) # N W E S
print dice.dicing(direction)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
class Dice:
    def __init__(self):
        self.top_label = 1
        self.N = 0; self.W = 1; self.E = 2; self.S = 3
        self.all_label = [0 for i in range(6)]
        self.index = {}
        self.array = [[2,3,4,6],[6,3,4,1],[6,5,2,1],[6,2,5,1],[6,4,3,1],[1,3,4,2]]
    def set_label(self,label):
        for i in range(6):
            self.all_label[i] = label[i]
    def calculate(self): 
        for i in range(6):
            for j in range(4):
                self.array[i][j] = self.all_label[self.array[i][j] - 1]
        for i in range(6):
            self.index[self.all_label[i]] = i
    def dicing(self,direction):
        d = 0
        for i in direction:
            if i == 'N':
                d = self.N
            elif i == 'W':
                d = self.W
            elif i == 'E':
                d = self.E
            elif i == 'S':
                d = self.S
            self.top_label = self.array[self.index[self.top_label]][d]
        return self.top_label

dice = Dice()
dice.set_label(map(int, raw_input().split()))
dice.calculate()
direction = list(raw_input())
print dice.dicing(direction)

Submission status: Wrong Answer

Solution code:
def roll(dice, commands):
    news = {
    'N':(1, 5, 2, 3, 0, 4),
    'S':(4, 0, 2, 3, 5, 1),
    'E':(0, 3, 1, 4, 2, 5),
    'W':(0, 2, 4, 1, 3, 5)
    }
    for c in commands:
        dice = [dice[i] for i in news[c]]
    return dice

if __name__ == '__main__':
    dice = input().split()
    dice = roll(dice, input())
    print(dice[1])

Submission status: Wrong Answer

Solution code:
def dice():
	dice = list(map(str, input().split()))
	direction = input()
	for i in range(len(direction)):
		if direction[i] == "N":
			dice[0],dice[1],dice[4],dice[5] = dice[1],dice[5],dice[0],dice[4]
		elif direction[i] == "S":
			dice[0],dice[1],dice[4],dice[5] = dice[4],dice[0],dice[5],dice[1]
		elif direction[i] == "W":
			dice[0],dice[2],dice[3],dice[5] = dice[2],dice[5],dice[0],dice[3]
		else :
			dice[0],dice[2],dice[3],dice[5] = dice[3],dice[0],dice[5],dice[2]
	print(dice[0])

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
s = input()
for c in s:
  if c == "S":
    l = [l[4], l[0], l[2], l[3], l[1], l[5]]
  elif c == "N":
    l = [l[1], l[5], l[2], l[3], l[4], l[0]]
  elif c == "E":
    l = [l[3], l[1], l[0], l[5], l[4], l[2]]
  else:
    l = [l[2], l[1], l[5], l[0], l[4], l[3]]
print(l[0])

Submission status: Wrong Answer

Solution code:
all_list = list(map(int, input().split()))
shiji = list(input())
for x in range(len(shiji)):
    print(all_list)
    if shiji[x] == 'S':
        all_list[0], all_list[1], all_list[5], all_list[4] = all_list[1], all_list[5], all_list[4], all_list[0]
    elif shiji[x] == 'N':
        all_list[1], all_list[5], all_list[4], all_list[0] = all_list[0], all_list[1], all_list[5], all_list[4]
    elif shiji[x] == 'W':
        all_list[3], all_list[5], all_list[2], all_list[0] = all_list[0], all_list[3], all_list[5], all_list[2]
    elif shiji[x] == 'E':
        all_list[0], all_list[3], all_list[5], all_list[2] = all_list[3], all_list[5], all_list[2], all_list[0]

print(all_list[0])

Submission status: Wrong Answer

Solution code:
all_list = list(map(int, input().split()))
shiji = list(input())
for x in range(len(shiji)):
    if shiji[x] == 'S':
        all_list[0], all_list[1], all_list[5], all_list[4] = all_list[1], all_list[5], all_list[4], all_list[0]
    elif shiji[x] == 'N':
        all_list[1], all_list[5], all_list[4], all_list[0] = all_list[0], all_list[1], all_list[5], all_list[4]
    elif shiji[x] == 'W':
        all_list[3], all_list[5], all_list[2], all_list[0] = all_list[0], all_list[3], all_list[5], all_list[2]
    elif shiji[x] == 'E':
        all_list[0], all_list[3], all_list[5], all_list[2] = all_list[3], all_list[5], all_list[2], all_list[0]

print(all_list[0])

Submission status: Wrong Answer

Solution code:
def north(list):
    List = []
    List.append(list[1])
    List.append(list[5])
    List.append(list[2])
    List.append(list[3])
    List.append(list[0])
    return List

def west(list):
    List = []
    List.append(list[2])
    List.append(list[1])
    List.append(list[5])
    List.append(list[0])
    List.append(list[4])
    List.append(list[3])
    return List
    
def south(list):
    List = []
    List.append(list[4])
    List.append(list[0])
    List.append(list[2])
    List.append(list[3])
    List.append(list[5])
    List.append(list[1])
    return List

def east(list):
    List = []
    List.append(list[3])
    List.append(list[1])
    List.append(list[0])
    List.append(list[5])
    List.append(list[4])
    List.append(list[2])
    return List

dice = list(map(int, input().split()))
x = str(input())
y = list(x)
for i in range(len(x)):
    if y[i] == 'N':
        dice[0:5] = north(dice)
    elif y[i] == 'W':
        dice[0:5] = west(dice)
    elif y[i] == 'S':
        dice[0:5] = south(dice)
    elif y[i] == 'E':
        dice[0:5] = east(dice)
print(dice[0])

Submission status: Wrong Answer

Solution code:
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.t=t
        self.f=f
        self.r=r
        self.l=l
        self.b=b
        self.u=u
    def roll(self,i):
        if d=='S':
            key=self.t
            self.t=self.b
            self.b=self.u
            self.u=self.f
            self.t=key
        elif d=='E':
            key=self.t
            self.t=self.l
            self.l=self.u
            self.u=self.r
            self.r=key
        elif d=='N':
            key=self.t
            self.t=self.f
            self.f=self.u
            self.u=self.b
            self.b=key
        else:
            key=self.t
            self.t=self.r
            self.r=self.u
            self.u=self.l
            self.l=key
t,f,r,l,b,u=map(int,input().split())
a=list(input())
dice=Dice(t,f,r,l,b,u)
for d in a:
    dice.roll(d)
print(dice.t)

Submission status: Wrong Answer

Solution code:
class Dice:
    
    def __init__(self, val):
        self.top = val[0]
        self.flat1 = val[1]
        self.flat2 = val[2]
        self.flat3 = val[3]
        self.flat4 = val[4]
        self.bottom = val[5]
        
    def doSouth(self):
        temp = self.bottom
        self.bottom = self.flat2
        self.flat2 = self.top
        self.top = temp

    def doNorth(self):
        temp = self.top
        self.top = self.flat2
        self.flat2 = self.bottom
        self.bottom = temp

    def doWest(self):
        temp = self.bottom
        self.top = self.flat3
        self.flat1 = self.top
        self.bottom = self.flat1
        self.flat3 = temp

    def doEast(self):
        temp = self.bottom
        self.top = self.flat1
        self.flat3 = self.top
        self.bottom = self.flat3
        self.flat1 = temp

def transform(dice, motion):
    if motion == 'S':
        dice.doSouth()
    elif motion == 'N':
        dice.doNorth()
    elif motion == 'W':
        dice.doWest()
    elif motion == 'E':
        dice.doEast()

N = input().split()
dice = Dice(N)
motion = input()
for i in range(len(motion)):
    transform(dice, motion[i])
print(dice.top)

Submission status: Wrong Answer

Solution code:
class Dice:
    
    def __init__(self, val):
        self.top = val[0]
        self.flat1 = val[1]
        self.flat2 = val[2]
        self.flat3 = val[3]
        self.flat4 = val[4]
        self.bottom = val[5]
        
    def doSouth(self):
        temp = self.bottom
        self.bottom = self.flat2
        self.flat2 = self.top
        self.top = temp

    def doNorth(self):
        temp = self.top
        self.top = self.flat2
        self.flat2 = self.bottom
        self.bottom = temp

    def doEast(self):
        temp = self.bottom
        self.top = self.flat3
        self.flat1 = self.top
        self.bottom = self.flat1
        self.flat3 = temp

    def doWest(self):
        temp = self.bottom
        self.top = self.flat1
        self.flat3 = self.top
        self.bottom = self.flat3
        self.flat1 = temp

def transform(dice, motion):
    if motion == 'S':
        dice.doSouth()
    elif motion == 'N':
        dice.doNorth()
    elif motion == 'W':
        dice.doWest()
    elif motion == 'E':
        dice.doEast()

N = input().split()
dice = Dice(N)
motion = input()
for i in range(len(motion)):
    transform(dice, motion[i])
print(dice.top)

Submission status: Wrong Answer

Solution code:
class Dice:
    
    def __init__(self, val):
        self.top = val[0]
        self.flat1 = val[3]
        self.flat2 = val[1]
        self.flat3 = val[2]
        self.flat4 = val[4]
        self.bottom = val[5]
        
    def doSouth(self):
        temp = self.bottom
        self.bottom = self.flat2
        self.flat2 = self.top
        self.top = self.flat4
        self.flat4 = temp

    def doNorth(self):
        temp = self.bottom
        self.bottom = self.flat4
        self.flat4 = self.top
        self.top = self.flat2
        self.flat4 = temp

    def doWest(self):
        temp = self.top
        self.top = self.flat3
        self.flat3 = self.bottom
        self.bottom = self.flat1
        self.flat1 = temp


    def doEast(self):
        temp = self.top
        self.top = self.flat1
        self.flat1 = self.bottom
        self.bottom = self.flat3
        self.flat3 = temp
    
    def doget(self):
        list = [self.top, self.flat2, self.flat3, self.flat1, self.flat4, self.bottom]
        return(list)

def transform(dice, motion):
    if motion == 'S':
        dice.doSouth()
    elif motion == 'N':
        dice.doNorth()
    elif motion == 'W':
        dice.doWest()
    elif motion == 'E':
        dice.doEast()

N = input().split()
dice = Dice(N)
motion = input()
for i in range(len(motion)):
    transform(dice, motion[i])
print(dice.top)

Submission status: Accepted

Solution code:
class Daise:
    def __init__(self, info_list):
        self.T = info_list[0]
        self.S = info_list[1]
        self.E = info_list[2]
        self.W = info_list[3]
        self.N = info_list[4]
        self.B = info_list[5]
    
    def change(self, axis):
        if axis == 'S':
            self.T, self.B, self.S, self.N = self.N, self.S, self.T, self.B
        
        elif axis == 'E':
            self.T, self.B, self.E, self.W = self.W, self.E, self.T, self.B
        
        elif axis == 'W':
            self.T, self.B, self.W, self.E = self.E, self.W, self.T, self.B
        
        elif axis == 'N':
            self.T, self.B, self.N, self.S = self.S, self.N, self.T, self.B


if __name__ == '__main__':
    info = list(map(str, input().split()))
    axis = str(input())
    obj = Daise(info)

    for i in axis:
        obj.change(i)
    print(obj.T)

Submission status: Accepted

Solution code:
class Dice:

    def __init__(self):
        # 初期値がない場合
        self.t = 1
        self.s = 2
        self.e = 4
        self.w = 8
        self.n = 16
        self.b = 32

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b

    def rot(self, way):
        if way == "S":
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == "N":
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == "E":
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == "W":
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        
        
def main():

    t,s,e,w,n,b = map(int, input().split())
    cmd = input().upper()
    dice1 = Dice(t,s,e,w,n,b)

    for i in range(len(cmd)):
        dice1.rot(cmd[i])
    
    print(dice1.t)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, dice: list):
        self.top = dice[0]
        self.bottom = dice[5]
        self.front = dice[1]
        self.behind = dice[4]
        self.right = dice[2]
        self.left = dice[3]

    def roll(self, direction: str):
        buffer = self.top
        if direction == 'E':
            self.top = self.left
            self.left = self.bottom
            self.bottom = self.right
            self.right = buffer
        elif direction == 'N':
            self.top = self.front
            self.front = self.bottom
            self.bottom = self.behind
            self.behind = buffer
        elif direction == 'S':
            self.top = self.behind
            self.behind = self.bottom
            self.bottom = self.front
            self.front = buffer
        else:
            self.top = self.right
            self.right = self.bottom
            self.bottom = self.left
            self.left = buffer


def main():
    dice1 = Dice(list(map(int, input().split())))
    for direction in input():
        dice1.roll(direction)
    print(dice1.top)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
for d in input():
	b = []
	if d == "N":
		b = [a[1], a[5], a[2], a[3], a[0], a[4]]
	elif d == "E":
		b = [a[3], a[1], a[0], a[5], a[4], a[2]]
	elif d == "S":
		b = [a[4], a[0], a[2], a[3], a[5], a[1]]
	else:
		b = [a[2], a[1], a[5], a[0], a[4], a[3]]
	a = b
print(a[0])

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
for d in input():
	if d == "N":
		a = [a[1], a[5], a[2], a[3], a[0], a[4]]
	elif d == "E":
		a = [a[3], a[1], a[0], a[5], a[4], a[2]]
	elif d == "S":
		a = [a[4], a[0], a[2], a[3], a[5], a[1]]
	else:
		a = [a[2], a[1], a[5], a[0], a[4], a[3]]
print(a[0])

Submission status: Accepted

Solution code:
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
  
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Submission status: Accepted

Solution code:
dice = list(map(int, input().split()))
command = str(input())

for c in command:
    if (c == 'S'): ##2651 --> 1265
        dice[1],dice[5],dice[4],dice[0] = dice[0],dice[1],dice[5],dice[4]
    elif(c == 'N'):
        dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
    elif (c == 'W'): ##4631 -- > 1463
        dice[3], dice[5], dice[2],dice[0] = dice[0], dice[3], dice[5], dice[2]
    else:
        dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2],dice[0] 
print(dice[0])

Submission status: Accepted

Solution code:
"""
  1
4 2 3 5
  6
  
"""

class Dice:
    def __init__(self, top, front, right, left, rear, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.rear = rear
        self.bottom = bottom

    def N(self):
        self.tmp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.rear
        self.rear = self.tmp

    def E(self):
        self.tmp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = self.tmp

    def S(self):
        self.tmp = self.top
        self.top = self.rear
        self.rear = self.bottom
        self.bottom = self.front
        self.front = self.tmp

    def W(self):
        self.tmp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = self.tmp

    def show_numbers(self):
        print("上：%d"% self.top)
        print("前：%d"% self.front)
        print("右：%d"% self.right)
        print("左：%d"% self.left)
        print("後：%d"% self.rear)
        print("底：%d"% self.bottom)

    def show_top(self):
        print("%d" % self.top)


# ここからプログラム
buf = input().split(" ")
dice1 = Dice(int(buf[0]), int(buf[1]), int(buf[2]), int(buf[3]), int(buf[4]), int(buf[5]))

buf = input()
for ch in buf:
    if ch == "N":
        dice1.N()
    elif ch == "E":
        dice1.E()
    elif ch == "S":
        dice1.S()
    elif ch == "W":
        dice1.W()

dice1.show_top()

Submission status: Accepted

Solution code:
def DICE(dice,dir):
    if dir == "N":
        dice[0],dice[1],dice[4],dice[5] = dice[1],dice[5],dice[0],dice[4]
    elif dir == "S":
        dice[0],dice[1],dice[4],dice[5] = dice[4],dice[0],dice[5],dice[1]
    elif dir == "E":
        dice[0],dice[2],dice[3],dice[5] = dice[3],dice[0],dice[5],dice[2]
    elif dir == "W":
        dice[0],dice[2],dice[3],dice[5] = dice[2],dice[5],dice[0],dice[3]
    return dice

tmp = raw_input().split()
s = raw_input()
for i in s:
    tmp = DICE(tmp, i)
print tmp[0]

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,num):
        self.num = num.copy()
        
    def east(self):
        temp = self.num.copy()
        self.num[1-1] = temp[4-1]
        self.num[4-1] = temp[6-1]
        self.num[6-1] = temp[3-1]
        self.num[3-1] = temp[1-1]

    def north(self):
        temp = self.num.copy()
        self.num[1-1] = temp[2-1]
        self.num[2-1] = temp[6-1]
        self.num[6-1] = temp[5-1]
        self.num[5-1] = temp[1-1]

    def south(self):
        temp = self.num.copy()
        self.num[1-1] = temp[5-1]
        self.num[5-1] = temp[6-1]
        self.num[6-1] = temp[2-1]
        self.num[2-1] = temp[1-1]

    def west(self):
        temp = self.num.copy()
        self.num[1-1] = temp[3-1]
        self.num[3-1] = temp[6-1]
        self.num[6-1] = temp[4-1]
        self.num[4-1] = temp[1-1]

num = list(map(int,input().split()))
dice = Dice(num)
command = input()
for c in command:
    if   c == 'E': dice.east()
    elif c == 'N': dice.north()
    elif c == 'S': dice.south()
    elif c == 'W': dice.west()
print(dice.num[0])

Submission status: Accepted

Solution code:
c=[int(i) for i in input().split()]
S=input()
d=[(0,0,1),(-1,0,0),(0,1,0),(0,-1,0),(1,0,0),(0,0,-1)]
def north(r):
    res=[]
    for p in r:
        res.append((p[2],p[1],-p[0]))
    return res
def south(r):
    res=[]
    for p in r:
        res.append((-p[2],p[1],p[0]))
    return res
def east(r):
    res=[]
    for p in r:
        res.append((p[0],p[2],-p[1]))
    return res
def west(r):
    res=[]
    for p in r:
        res.append((p[0],-p[2],p[1]))
    return res
D=[i for i in d]
for i in S:
    if i=="N":
        D=north(D)
    elif i=="S":
        D=south(D)
    elif i=="W":
        D=west(D)
    else:
        D=east(D)
for k in range(6):
    if D[k]==(0,0,1):
        print(c[k])

Submission status: Accepted

Solution code:
labels = input().split()
copy = [0, 0, 0, 0, 0, 0]
order = input()
rolls = {'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
for d in order:
    roll = rolls[d]
    labels = [labels[i] for i in roll]
print(labels[0])

Submission status: Accepted

Solution code:
from sys import stdin

class Dice:
    def __init__(self, nums):
        self._1 = nums[0]
        self._2 = nums[1]
        self._3 = nums[2]
        self._4 = nums[3]
        self._5 = nums[4]
        self._6 = nums[5]
        self.pos = {
            "E" : self._3,
            "W" : self._4,
            "S" : self._2,
            "N" : self._5,
            "T" : self._1,
            "B" : self._6
        }

    def roll(self, query):
        for q in query:
            if q == "E":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["W"], self.pos["T"], self.pos["E"], self.pos["B"]
            elif q == "W":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["E"], self.pos["B"], self.pos["W"], self.pos["T"]
            elif q == "S":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["N"], self.pos["T"], self.pos["S"], self.pos["B"]
            elif q == "N":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["S"], self.pos["B"], self.pos["N"], self.pos["T"]

nums = [int(x) for x in stdin.readline().rstrip().split()]
queries = stdin.readline().rstrip()
d = Dice(nums)
d.roll(queries)
print(d.pos["T"])

Submission status: Accepted

Solution code:
from sys import stdin

class Dice:
    def __init__(self, nums):
        self.labels = {
            "1" : nums[0],
            "2" : nums[1],
            "3" : nums[2],
            "4" : nums[3],
            "5" : nums[4],
            "6" : nums[5]
        }
        self.pos = {
            "E" : "3",
            "W" : "4",
            "S" : "2",
            "N" : "5",
            "T" : "1",
            "B" : "6"
        }

    def roll(self, query):
        for q in query:
            if q == "E":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["W"], self.pos["T"], self.pos["E"], self.pos["B"]
            elif q == "W":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["E"], self.pos["B"], self.pos["W"], self.pos["T"]
            elif q == "S":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["N"], self.pos["T"], self.pos["S"], self.pos["B"]
            elif q == "N":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["S"], self.pos["B"], self.pos["N"], self.pos["T"]

nums = [int(x) for x in stdin.readline().rstrip().split()]
queries = stdin.readline().rstrip()
d = Dice(nums)
d.roll(queries)
print(d.labels[d.pos["T"]])

Submission status: Accepted

Solution code:
from typing import List


class Dice:

    def __init__(self, surface: List[int]):
        self.surface = surface

    def get_upper_sursurface(self) -> int:
        return self.surface[0]

    def invoke_method(self, mkey: str) -> None:
        print(type(mkey))
        if mkey == 'S':
            self.S()
        if mkey == 'N':
            self.N()
        if mkey == 'E':
            self.E()
        if mkey == 'W':
            self.W()
        raise ValueError(f'This method does not exist. : {mkey}')

    def S(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[4]
        self.surface[1] = tmp[0]
        self.surface[2] = tmp[2]
        self.surface[3] = tmp[3]
        self.surface[4] = tmp[5]
        self.surface[5] = tmp[1]

    def N(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[1]
        self.surface[1] = tmp[5]
        self.surface[2] = tmp[2]
        self.surface[3] = tmp[3]
        self.surface[4] = tmp[0]
        self.surface[5] = tmp[4]

    def E(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[3]
        self.surface[1] = tmp[1]
        self.surface[2] = tmp[0]
        self.surface[3] = tmp[5]
        self.surface[4] = tmp[4]
        self.surface[5] = tmp[2]

    def W(self) -> None:
        tmp = [i for i in self.surface]
        self.surface[0] = tmp[2]
        self.surface[1] = tmp[1]
        self.surface[2] = tmp[5]
        self.surface[3] = tmp[0]
        self.surface[4] = tmp[4]
        self.surface[5] = tmp[3]


data = [int(i) for i in input().split()]
order = list(input())
# data = [int(i) for i in '1 2 4 8 16 32'.split()]
# order = list('EESWN')

dice = Dice(data)
for o in order:
    if o == 'S':
        dice.S()
    if o == 'N':
        dice.N()
    if o == 'E':
        dice.E()
    if o == 'W':
        dice.W()

    # dice.invoke_method(o)
print(dice.get_upper_sursurface())