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: Accepted

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

    def rotate(self,dir):
        if dir=="N":
            tmp=self.val[0]
            self.val[0]=self.val[1]
            self.val[1]=self.val[5]
            self.val[5]=self.val[4]
            self.val[4]=tmp
        if dir=="E":
            tmp=self.val[0]
            self.val[0]=self.val[3]
            self.val[3]=self.val[5]
            self.val[5]=self.val[2]
            self.val[2]=tmp
        if dir=="S":
            tmp=self.val[0]
            self.val[0]=self.val[4]
            self.val[4]=self.val[5]
            self.val[5]=self.val[1]
            self.val[1]=tmp
        if dir=="W":
            tmp=self.val[0]
            self.val[0]=self.val[2]
            self.val[2]=self.val[5]
            self.val[5]=self.val[3]
            self.val[3]=tmp


x = list(map(int,input().split()))
char = list(input())
#print(char)

D = Dice(x)

for word in char:
    D.rotate(word)

print(D.val[0])

Submission status: Accepted

Solution code:
def test():

	faces = list(map(int,input().split()))
	command_stream = list(input())

	for command in command_stream:

		tmp_face = []
		for face in faces:
			tmp_face.append(face)

		#S:1->2,2->6,6->5,5->1
		if command == 'S':
			faces[0] = tmp_face[4]
			faces[4] = tmp_face[5]
			faces[5] = tmp_face[1]
			faces[1] = tmp_face[0]
		#N:1->5,5->6,6->2,2->1
		elif command == 'N':
			faces[0] = tmp_face[1]
			faces[1] = tmp_face[5]
			faces[5] = tmp_face[4]
			faces[4] = tmp_face[0]
		#W:1->4,4->6,6->3,3->1
		elif command == 'W':
			faces[0] = tmp_face[2]
			faces[2] = tmp_face[5]
			faces[5] = tmp_face[3]
			faces[3] = tmp_face[0]
		#E:1->3,3->6,6->4,4->1
		elif command == 'E':
			faces[0] = tmp_face[3]
			faces[3] = tmp_face[5]
			faces[5] = tmp_face[2]
			faces[2] = tmp_face[0]

	print(faces[0])

if __name__ == "__main__":
	test()

Submission status: Accepted

Solution code:
class dice:
    def __init__(self, lable):
        self.top, self.front, self.right, self.left, self.rear, self.bottom = label
    
    def roll(self, odr):
        if odr == 'N': self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
        elif odr == 'E': self.top, self.left, self.bottom, self.right = \
            self.left, self.bottom, self.right, self.top
        elif odr == 'W': self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top
        elif odr == '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()))
odr_list = list(input())
d = dice(label)
for odr in odr_list:
    d.roll(odr)
d.print_top()

Submission status: Accepted

Solution code:
#ITP1_11_A

def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)
	else          : raise AssertionError()

def dump(d):
	print(" ".join(map(str,d)))

def inputDice():
	return list(map(int,("-1 "+input()).split()))

d=inputDice()
for op in list(input()):
	kaiten(d,op)
print(d[1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import copy
line = sys.stdin.readline() 
line = line.rstrip('\r\n')
face = line.split()

line = sys.stdin.readline() 
line = line.rstrip('\r\n')

for i in line:
    face_old = copy.deepcopy(face)
    if i == "E":
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    elif i == "N":
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    elif i == "S":
        face[0] = face_old[4]
        face[1] = face_old[0]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[5]
        face[5] = face_old[1]
    else:
        face[0] = face_old[2]
        face[1] = face_old[1]
        face[2] = face_old[5]
        face[3] = face_old[0]
        face[4] = face_old[4]
        face[5] = face_old[3]

print(face[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()))
slist = input()
 
for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")
 
    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]
 
    dice = tmp
 
print(dice[0])

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
 
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def get_Top(self):
        return self.number[0]
 
 
dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)
 
print("%d"%(dice.get_Top()))

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, num, dire):
        self.num = num
        self.dir = dire

    def rotate(self):
        for hou in self.dir:
            if hou == "S":
                self.num[0], self.num[4], self.num[5], self.num[1] = self.num[4], self.num[5], self.num[1], self.num[0]
                tile = self.num[0]
            if hou == "W":
                self.num[0], self.num[2], self.num[5], self.num[3] = self.num[2], self.num[5], self.num[3], self.num[0]
                tile = self.num[0]
            if hou == "N":
                self.num[0], self.num[1], self.num[5], self.num[4] = self.num[1], self.num[5], self.num[4], self.num[0]
                tile = self.num[0]
            if hou == "E":
                self.num[0], self.num[3], self.num[5], self.num[2] = self.num[3], self.num[5], self.num[2], self.num[0]
                tile = self.num[0]
        return tile


s = list(map(int, input().split()))
t = list(input())
idice = Dice(s, t)
print(idice.rotate())

Submission status: Accepted

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

order = input()
a1,a2,a3,a4,b1,b2 = 1,5,6,2,3,4

#print(a1,a2,a3,a4,b1,b2)
#print(order)
for i in order:
  if i == 'N':
    a_1 = a4
    a_2 = a1
    a_3 = a2
    a_4 = a3
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  elif i == 'S':
    a_1 = a2
    a_2 = a3
    a_3 = a4
    a_4 = a1
    b_1 = b1
    b_2 = b2
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  elif i == 'E':
    a_1 = b2
    a_2 = a2
    b_1 = a1
    a_3 = b1
    b_2 = a3
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
  else:
    a_1 = b1
    b_1 = a3
    a_3 = b2
    b_2 = a1
    a_2 = a2
    a_4 = a4
    a1,a2,a3,a4,b1,b2 = a_1,a_2,a_3,a_4,b_1,b_2
    #print(a1,a2,a3,a4,b1,b2)
    
print(n[int(a1)-1])

Submission status: Accepted

Solution code:
class Dice:
    # 0: top, 1: front, 2: right, 3: left, 4: back, 5: bottom
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

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

n = list(map(int, input().split()))
dice = Dice(n[0], n[1], n[2], n[3], n[4], n[5])
cmd = input()
for op in cmd:
    dice.move(op)
print(dice.top())

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c
 
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
st=input()
for c in st:
    dice.rot(c)
print(dice.u)

Submission status: Accepted

Solution code:
#我不知道怎么定义结构体，我是直接模拟的    QAQ
start = [1,2,3,5,4,6]

def N():
    start[0],start[1],start[3],start[5] = \
    start[1],start[5],start[0],start[3]
    
def S():
    start[0],start[1],start[3],start[5] = \
    start[3],start[0],start[5],start[1]
    
def W():
    start[0],start[2],start[4],start[5] = \
    start[2],start[5],start[0],start[4]

def E():
    start[0],start[2],start[4],start[5] = \
    start[4],start[0],start[5],start[2]

if __name__ == "__main__":
    lst = list(map(int,input().split()))
    s = input()
    for i in range(len(s)):
        if s[i]=='S':
            S()
        if s[i]=='E':
            E()
        if s[i]=='W':
            W()
        if s[i]=='N':
            N()
    print(lst[start[0]-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mask = {'N':(1, 5, 2, 3, 0, 4), 'E':(3, 1, 0, 5, 4, 2), 'S':(4, 0, 2, 3, 5, 1), 'W':(2, 1, 5, 0, 4,3)}

dice = input().split()

for c in input():
    dice = [dice[i] for i in mask[c]]

print(dice[0])

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))

Submission status: Accepted

Solution code:
s = list(map(int,input().split()))
ORDER = input()
order = list(ORDER)

for i in order:
  if i == 'E':
    s[0], s[3] = s[3], s[0]
    s[3], s[5] = s[5], s[3]
    s[5], s[2] = s[2], s[5]
    
  if i == 'N':
    s[0], s[1] = s[1], s[0]
    s[1], s[5] = s[5], s[1]
    s[5], s[4] = s[4], s[5]
    
    
  if i == 'S':
    s[0], s[4] = s[4], s[0]
    s[4], s[5] = s[5], s[4]
    s[5], s[1] = s[1], s[5] 
    
  if i == 'W':
    s[0], s[2] = s[2], s[0]
    s[2], s[5] = s[5], s[2]
    s[5], s[3] = s[3], s[5]

print(s[0])

Submission status: Accepted

Solution code:
#0:上面 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  #[0, 1, 2, 3, 4, 5]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


# n = list(map(int, input().split()))
dice = Dice()
n = list(map(int, input().split()))
dice.setNumber(n[0], n[1], n[2], n[3], n[4], n[5])
directions = input()
for direction in directions:
    dice.roll(direction)
print(dice.get_Top())

Submission status: Accepted

Solution code:
def rot(s):
    if s=="E":
        return [4,2,1,6,5,3]
    elif s=="W":
        return [3,2,6,1,5,4]
    elif s=="S":
        return [5,1,3,4,6,2]
    elif s=="N":
        return [2,6,3,4,1,5]
    
label = tuple(map(int,input().split()))
surf = [0,1,2,3,4,5]
l = [0,0,0,0,0,0]
com = list(input())
for c in com:
    l = rot(c)
    surf[0],surf[1],surf[2],surf[3],surf[4],surf[5]=surf[l[0]-1],surf[l[1]-1],surf[l[2]-1],surf[l[3]-1],surf[l[4]-1],surf[l[5]-1]
print(label[surf[0]])

Submission status: Accepted

Solution code:
d = input().split()
s = {"N":"152304", "W":"215043", "E":"310542", "S":"402351"}
for o in input():
  d = [d[int(i)] for i in s[o]]
print(d[0])

Submission status: Accepted

Solution code:
l=map(int,raw_input().split())
n=raw_input()
ans=chk=0
 
 
def rolling(word,dice):
    if word=='S':
        dice[0],dice[1],dice[5],dice[4]=dice[4],dice[0],dice[1],dice[5]
    elif word=='N':
        dice[0],dice[1],dice[5],dice[4]=dice[1],dice[5],dice[4],dice[0]
    elif word=='W':
        dice[0],dice[2],dice[5],dice[3]=dice[2],dice[5],dice[3],dice[0]
    else:
        dice[0],dice[2],dice[5],dice[3]=dice[3],dice[0],dice[2],dice[5]
    return dice
 
for i in n:
    l=rolling(i,l)
print l[0]

Submission status: Accepted

Solution code:
r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}

d=input().split()   
for x in input(): 
    d=[d[y]for y in r[x]]   
    
print(d[0])

Submission status: Accepted

Solution code:
class Movedice:
    def __init__(self,list,position):
        self.list=list
        self.position=position
    def sortnumber(self):
        self.list[0],self.list[self.position]=self.list[self.position],self.list[0]
        self.list[5-self.position],self.list[5]=self.list[5],self.list[5-self.position]
        self.list[0],self.list[5]=self.list[5],self.list[0]
        return list

number=list(map(int,input().split()))
destination=list(input())
for i in range(len(destination)):
    if destination[i]=='N':
        movedice=Movedice(number,4)
        movedice.sortnumber()
    elif destination[i]=='E':
        movedice=Movedice(number,2)
        movedice.sortnumber()
    elif destination[i]=='W':
        movedice=Movedice(number,3)
        movedice.sortnumber()
    else:
        movedice=Movedice(number,1)
        movedice.sortnumber()
print(number[0])

Submission status: Accepted

Solution code:
def roll_positive(list_a: list, list_b: list) -> list:
    list_a = list_a[1:] + list_a[0:1]  # Roll one unit in the positive direction.
    list_b[0] = list_a[0]  # Change the bottom face.
    list_b[2] = list_a[2]  # Change the top face.
    return [list_a, list_b]


def roll_negative(list_a: list, list_b: list) -> list:
    list_a = list_a[3:] + list_a[0:3]
    list_b[0] = list_a[0]  # Change the bottom face.
    list_b[2] = list_a[2]  # Change the top face.
    return [list_a, list_b]


if __name__ == "__main__":
    faces_int = list(map(lambda x: int(x), input().split()))  # 1,2,3,4,5,6
    SN_direction = [faces_int[5], faces_int[4], faces_int[0], faces_int[1]]  # 6,5,1,2
    WE_direction = [faces_int[5], faces_int[2], faces_int[0], faces_int[3]]  # 6,3,1,4
    commands = input()

    for command in commands:
        if ("N" == command):
            SN_direction, WE_direction = roll_positive(SN_direction, WE_direction)
        elif ("S" == command):
            SN_direction, WE_direction = roll_negative(SN_direction, WE_direction)
        elif ("E" == command):
            WE_direction, SN_direction = roll_positive(WE_direction, SN_direction)
        else:
            WE_direction, SN_direction = roll_negative(WE_direction, SN_direction)

    print(f"{SN_direction[2]}")  # Print the opposite face of the bottom.

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0],
                           self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2],
                           self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2],
                           self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5],
                           self.work[0], self.work[4], self.work[3])

    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d" % (dice.get_Top()))

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
order = list(input())

for i in range(len(order)):
    if order[i] == 'E':
        temp = n[0]
        n[0] = n[3]
        n[3] = n[5]
        n[5] = n[2]
        n[2] = temp
    elif order[i] == 'W':
        temp = n[0]
        n[0] = n[2]
        n[2] = n[5]
        n[5] = n[3]
        n[3] = temp
    elif order[i] == 'S':
        temp = n[0]
        n[0] = n[4]
        n[4] = n[5]
        n[5] = n[1]
        n[1] = temp
    else:
        temp = n[0]
        n[0] = n[1]
        n[1] = n[5]
        n[5] = n[4]
        n[4] = temp

print(n[0])

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, a, b, c, d, e, f):
        self.top = a
        self.front = b
        self.right = c
        self.left = d
        self.behind = e
        self.bottom = f

    def S(self):
        self.top, self.front, self.behind, self.bottom = self.behind, self.top, self.bottom, self.front

    def N(self):
        self.behind, self.top, self.bottom, self.front = self.top, self.front, self.behind, self.bottom

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

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


dice=Dice(*[int(i) for i in input().split(" ")])
for s in input():
    if s=="S":
        dice.S()
    if s=="E":
        dice.E()
    if s=="N":
        dice.N()
    if s=="W":
        dice.W()
print(dice.top)

Submission status: Accepted

Solution code:
def rotateDice(direction: str, dice: dict) -> dict:
    if direction == 'S':
        dice['S'], dice['F'], dice['N'], dice['B'] = dice['F'], dice['N'], dice['B'], dice['S']
    elif direction == 'E':
        dice['E'], dice['F'], dice['W'], dice['B'] = dice['F'], dice['W'], dice['B'], dice['E']
    elif direction == 'W':
        dice['W'], dice['F'], dice['E'], dice['B'] = dice['F'], dice['E'], dice['B'], dice['W']
    elif direction == 'N':
        dice['N'], dice['F'], dice['S'], dice['B'] = dice['F'], dice['S'], dice['B'], dice['N']
    return dice
 
 
dice_list = list(map(int, input().split()))
dice = {'FSEWNB'[i]: dice_list[i] for i in range(6)}
for c in input():
    dice = rotateDice(c, dice)
print(dice['F'])

Submission status: Accepted

Solution code:
dice = list(map(int, input().split()))
order = input()
for i in range(len(order)):
  c = order[i]
  if c == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif c == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif c == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif c == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
print(dice[0])

Submission status: Accepted

Solution code:
d1,d2,d3,d4,d5,d6 =map(int,input().split())

a=input()

task=len(a)


for i in range(task):
	if a[i]=='E':
		d1,d2,d3,d4,d5,d6=d4,d2,d1,d6,d5,d3
	if a[i]=='N':
		d1,d2,d3,d4,d5,d6=d2,d6,d3,d4,d1,d5
	if a[i]=='S':
		d1,d2,d3,d4,d5,d6=d5,d1,d3,d4,d6,d2
	if a[i]=='W':
		d1,d2,d3,d4,d5,d6=d3,d2,d6,d1,d5,d4
print(d1)

Submission status: Accepted

Solution code:
class dice():
    
    def __init__(self,a,b,c,d,e,f):
        self.A=[a,b,c,d,e,f]
        self.temp=[]
        
    def N_method(self):
       for i in self.A:
        self.temp.append(i)       


       self.A[0]=self.temp[1]
       self.A[1]=self.temp[5]
       self.A[4]=self.temp[0]
       self.A[5]=self.temp[4]
       self.A[2]=self.temp[2]
       self.A[3]=self.temp[3]
       self.temp=[]
       #print(self.A[0])
    def S_method(self):
        for i in self.A:
           self.temp.append(i)
       
        self.A[0]=self.temp[4]
        self.A[1]=self.temp[0]
        self.A[2]=self.temp[2]
        self.A[3]=self.temp[3]
        self.A[4]=self.temp[5]
        self.A[5]=self.temp[1]
        self.temp=[]
        #print(self.A[0])
    def W_method(self):
       for i in self.A:
          self.temp.append(i)
       
       self.A[0]=self.temp[2]
       self.A[1]=self.temp[1]
       self.A[2]=self.temp[5]
       self.A[3]=self.temp[0]
       self.A[4]=self.temp[4]
       self.A[5]=self.temp[3]
       self.temp=[]
       #print(self.A[0])
    def E_method(self):
        for i in self.A:
            self.temp.append(i)
        
        self.A[0]=self.temp[3]
        self.A[1]=self.temp[1]
        self.A[2]=self.temp[0]
        self.A[3]=self.temp[5]
        self.A[4]=self.temp[4]
        self.A[5]=self.temp[2]
        self.temp=[]
        #print(self.A[0])
    
    def printout(self):
        print(self.A[0])
if __name__=="__main__":

    input_text=""
    input_text=input()
    array=[]
    array=input_text.split()

    ob1=dice(array[0],array[1],array[2],array[3],array[4],array[5])

    input_order=input()
    order_array=[]
    order_array=list(input_order)


    for i in range(0,len(order_array)):
        
        if order_array[i]=="E":
            ob1.E_method()
        elif order_array[i]=="S":
            ob1.S_method()
        elif order_array[i]=="W":
            ob1.W_method()
        elif order_array[i]=="N":
            ob1.N_method()
  
    ob1.printout()

Submission status: Accepted

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

	def dice_n(self):
		self.d[4],self.d[0],self.d[1],self.d[5] = self.d[0],self.d[1],self.d[5],self.d[4]

	def dice_s(self):
		self.d[0],self.d[4],self.d[5],self.d[1] = self.d[4],self.d[5],self.d[1],self.d[0]

	def dice_w(self):
		self.d[0],self.d[2],self.d[5],self.d[3] = self.d[2],self.d[5],self.d[3],self.d[0]

	def dice_e(self):
		self.d[0],self.d[3],self.d[5],self.d[2] = self.d[3],self.d[5],self.d[2],self.d[0]

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

if __name__ == '__main__':

	dd = list(map(int,input().split()))
	line = input()

	d = Dice()

	for di in line:
		if di == "N":
			d.dice_n()
		elif di == "S":
			d.dice_s()
		elif di == "W":
			d.dice_w()
		elif di == "E":
			d.dice_e()

	print(dd[d.get_top()])

Submission status: Accepted

Solution code:
a1,a2,a3,a4,a5,a6=map(int,input().split())
s=input()
for i in s:
    if i=="E":
        a1,a2,a3,a4,a5,a6=a4,a2,a1,a6,a5,a3
    elif i=="S":
        a1,a2,a3,a4,a5,a6=a5,a1,a3,a4,a6,a2
    elif i=="W":
        a1,a2,a3,a4,a5,a6=a3,a2,a6,a1,a5,a4
    elif i=="N":
        a1,a2,a3,a4,a5,a6=a2,a6,a3,a4,a1,a5
print(a1)

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, arr):
        self.arr = [0] + arr
        
    def rotate(self, string):
        if string == "S":
            self.arr[1], self.arr[2], self.arr[6], self.arr[5] = self.arr[5], self.arr[1], self.arr[2], self.arr[6]
        if string == "N":
            self.arr[5], self.arr[1], self.arr[2], self.arr[6] = self.arr[1], self.arr[2], self.arr[6], self.arr[5]
        if string == "E":
            self.arr[1], self.arr[3], self.arr[6], self.arr[4] = self.arr[4], self.arr[1], self.arr[3], self.arr[6]
        if string == "W":
            self.arr[4], self.arr[1], self.arr[3], self.arr[6] = self.arr[1], self.arr[3], self.arr[6], self.arr[4]

    def top(self):
        return self.arr[1]


arr = list(map(int, input().split()))
dice = Dice(arr)
rotate = input()
for s in rotate:
    dice.rotate(s)
print(dice.top())

Submission status: Accepted

Solution code:
def rotate(l, d):
    if d == 'S':
        return [l[4], l[0], l[2], l[3], l[5], l[1]]
    if d == 'N':
        return [l[1], l[5], l[2], l[3], l[0], l[4]]
    if d == 'W':
        return [l[2], l[1], l[5], l[0], l[4], l[3]]
    if d == 'E':
        return [l[3], l[1], l[0], l[5], l[4], l[2]]

l = list(map(int, input().split()))
for c in input():
    l = rotate(l, c)

print(l[0])