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:
    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:
class dice:
    # top,down,right,left,up,back
    def rota(self, direction):
        if direction == "E":
            self.surface = [self.surface[3], self.surface[1], self.surface[0],
                            self.surface[5], self.surface[4], self.surface[2]]
        if direction == "W":
            self.surface = [self.surface[2], self.surface[1], self.surface[5],
                            self.surface[0], self.surface[4], self.surface[3]]
        if direction == "S":
            self.surface = [self.surface[4], self.surface[0], self.surface[2],
                            self.surface[3], self.surface[5], self.surface[1]]
        if direction == "N":
            self.surface = [self.surface[1], self.surface[5], self.surface[2],
                            self.surface[3], self.surface[0], self.surface[4]]


dice1 = dice()
dice1.surface = list(map(int, input().split()))

for i in input():
    dice1.rota(i)
print(dice1.surface[0])

Submission status: Accepted

Solution code:
# サイコロ        初期状態
#    [1]           N
# [4][2][3][5]   W[1]E
#    [6]           S
#
# 上記の順番でラベルに対する整数が与えられる
# l1 l2 l3 l4 l5 l6
# {N, E, W, S} ...
import sys

class Dice:
    def __init__(self, l1, l2, l3, l4, l5, l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.tmp = 0
    def move_n(self):
        self.tmp = self.l5
        self.l5 = self.l1
        self.l1 = self.l2
        self.l2 = self.l6
        self.l6 = self.tmp
    def move_s(self):
        self.tmp = self.l2
        self.l2 = self.l1
        self.l1 = self.l5
        self.l5 = self.l6
        self.l6 = self.tmp
    def move_e(self):
        self.tmp = self.l3
        self.l3 = self.l1
        self.l1 = self.l4
        self.l4 = self.l6
        self.l6 = self.tmp
    def move_w(self):
        self.tmp = self.l4
        self.l4 = self.l1
        self.l1 = self.l3
        self.l3 = self.l6
        self.l6 = self.tmp

d1 = Dice(*map(int, input().split()))

for line in sys.stdin:
    for s in list(line):
        if s == 'N':
            d1.move_n()
        elif s == 'S':
            d1.move_s()
        elif s == 'E':
            d1.move_e()
        elif s == 'W':
            d1.move_w()
print(d1.l1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

class Dice:

    def __init__(self,dicelist):
        self.dice_list = dicelist

    def roll(self, direction):
        work = list(self.dice_list)
        if (direction == 'N'):
            self.dice_list[0] = work[1]
            self.dice_list[1] = work[5]
            self.dice_list[2] = work[2]
            self.dice_list[3] = work[3]
            self.dice_list[4] = work[0]
            self.dice_list[5] = work[4]
        elif (direction == 'E'):
            self.dice_list[0] = work[3]
            self.dice_list[1] = work[1]
            self.dice_list[2] = work[0]
            self.dice_list[3] = work[5]
            self.dice_list[4] = work[4]
            self.dice_list[5] = work[2]
        elif (direction == 'S'):
            self.dice_list[0] = work[4]
            self.dice_list[1] = work[0]
            self.dice_list[2] = work[2]
            self.dice_list[3] = work[3]
            self.dice_list[4] = work[5]
            self.dice_list[5] = work[1]
        elif (direction == 'W'):
            self.dice_list[0] = work[2]
            self.dice_list[1] = work[1]
            self.dice_list[2] = work[5]
            self.dice_list[3] = work[0]
            self.dice_list[4] = work[4]
            self.dice_list[5] = work[3]

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

dice_list = list(map(int, stdin.readline().rstrip().split()))
dice = Dice(dice_list)

rolls = stdin.readline().rstrip()
for roll in rolls:
    dice.roll(roll)
else:
    print(dice.getTop())

Submission status: Accepted

Solution code:
up, south, east, west, north, down = map(int, input().split())
command = input()
for c in command:
    if c == 'N':
        copy = north
        north = up
        up = south
        south = down
        down = copy
    elif c == 'S':
        copy = north
        north = down
        down = south
        south = up
        up = copy
    elif c == 'W':
        copy = west
        west = up
        up = east
        east = down
        down = copy
    else:
        copy = west
        west = down
        down = east
        east = up
        up = copy
print(up)

Submission status: Accepted

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

for x in range(len(s)):
    if s[x:x+1] == "S":
        temp = D[0]
        D[0] = D[4]
        D[4] = D[5]
        D[5] = D[1]
        D[1] = temp
    elif s[x:x+1] == "W":
        temp = D[0]
        D[0] = D[2]
        D[2] = D[5]
        D[5] = D[3]
        D[3] = temp
    elif s[x:x+1] == "E":
        temp = D[0]
        D[0] = D[3]
        D[3] = D[5]
        D[5] = D[2]
        D[2] = temp
    elif s[x:x+1] == "N":
        temp = D[0]
        D[0] = D[1]
        D[1] = D[5]
        D[5] = D[4]
        D[4] = temp
    
print(D[0])

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def south(dice):
    f, u, d, b = [dice["front"], dice["up"], dice["down"], dice["back"]]
    dice["front"] = u
    dice["up"] = b
    dice["down"] = f
    dice["back"] = d
    return dice

def north(dice):
    f, u, d, b = [dice["front"], dice["up"], dice["down"], dice["back"]]
    dice["front"] = d
    dice["up"] = f
    dice["down"] = b
    dice["back"] = u
    return dice

def west(dice):
    d, l, r, u = [dice["down"], dice["left"], dice["right"], dice["up"]]
    dice["down"] = l
    dice["left"] = u
    dice["right"] = d
    dice["up"] = r
    return dice

def east(dice):
    d, l, r, u = [dice["down"], dice["left"], dice["right"], dice["up"]]
    dice["down"] = r
    dice["left"] = d
    dice["right"] = u
    dice["up"] = l
    return dice

def show(dice):
    print(" ", dice["up"], " ")
    print(dice["left"], dice["front"], dice["right"], dice["back"])
    print(" ", dice["down"], " ")
    print()

def init_dice(dice_data):
    return {
        "front": dice_data[1], "back": dice_data[4],
        "up": dice_data[0], "right": dice_data[2], "down": dice_data[5], "left": dice_data[3]
    }

def main():
    pos = list(map(int, input().split()))
    move = input().rstrip()
    dice = init_dice(pos)
    for i in move:
        if i == "W":
            dice = west(dice)
        elif i == "S":
            dice = south(dice)
        elif i == "N":
            dice = north(dice)
        elif i == "E":
            dice = east(dice)

    print(dice["up"])
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
class Dice:
    def __init__(self):
        #self.ms = ms
        self.number = [i for i in range(6)]
        self.dev = [i for i in range(6)]
    
    def set_num(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 dice_roll(self,event):
        for i in range(6):
            self.dev[i] = self.number[i]
        #0:上,1:南,2:東,3:西,4:北,5:下
        if event == "S":
            self.set_num(self.dev[4],self.dev[0],self.dev[2],self.dev[3],self.dev[5],self.dev[1])
        if event == "N":
            self.set_num(self.dev[1],self.dev[5],self.dev[2],self.dev[3],self.dev[0],self.dev[4])
        if event == "E":
            self.set_num(self.dev[3],self.dev[1],self.dev[0],self.dev[5],self.dev[4],self.dev[2])
        if event == "W":
            self.set_num(self.dev[2],self.dev[1],self.dev[5],self.dev[0],self.dev[4],self.dev[3])
    
    def get_top(self):
        #for i in range(len(self.number)):
            #print(self.number[i])
        #sys.exit()
        return self.number[0]

ms = list(map(int,input().split()))
dice = Dice()
dice.set_num(ms[0],ms[1],ms[2],ms[3],ms[4],ms[5])
events = list(str(input()))
for event in events:
    dice.dice_roll(event)

print(dice.get_top())

Submission status: Accepted

Solution code:
from enum import IntEnum

class Face(IntEnum):
    One=1
    Two=2
    Three=3
    Four=4
    Five=5
    Six=6


class Dice:
    def __init__(self):
        self.top=Face.One
        self.bottom=Face.Six
        self.back=Face.Two
        self.front=Face.Five
        self.left=Face.Four
        self.right=Face.Three
    
    def roll(self,command):
        if command=="E":
            #back-frontを軸として右回転
            temp=self.top
            self.top=self.left
            self.left=self.bottom
            self.bottom=self.right
            self.right=temp
            
        elif command=="N":
            #right-leftを固定して前転
            temp=self.top
            self.top=self.back
            self.back=self.bottom
            self.bottom=self.front
            self.front=temp
            
        elif command=="S":
            #right-leftを固定して後転
            temp=self.top
            self.top=self.front
            self.front=self.bottom
            self.bottom=self.back
            self.back=temp
            
        elif command=="W":
            #back-frontを軸として左回転
            temp=self.top
            self.top=self.right
            self.right=self.bottom
            self.bottom=self.left
            self.left=temp
            



def run():
    dice_score_ls=list(map(int,input().split()))
    command_str=input()
    
    dice_score_dict={i+1:score for i,score in enumerate(dice_score_ls)}
    
    dice=Dice()
    for command in command_str:
        dice.roll(command)
        

    final_score=dice_score_dict[int(dice.top)]
    print(f"{final_score}")


run()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self, numbers):
        self.dice = {"上" :numbers[0],
                     "下":numbers[5], 
                     "前":numbers[1],
                     "後":numbers[4],
                     "左":numbers[3],
                     "右":numbers[2]
                    }
    
    def order(self, order_seq):
        self.order_seq = order_seq
        for _, order in enumerate(self.order_seq):
            if order == "N":
                self.north()
            elif order == "E":
                self.east()
            elif order == "W":
                self.west()
            elif order == "S":
                self.south()
        
        return self.dice["上"]

    def north(self):
        U, D, F, B = [self.dice["上"], self.dice["下"], self.dice["前"], self.dice["後"]]
        self.dice["上"] = F
        self.dice["前"] = D
        self.dice["下"] = B
        self.dice["後"] = U

    def east(self):
        U, D, L, R = [self.dice["上"], self.dice["下"], self.dice["左"], self.dice["右"]]
        self.dice["上"] = L
        self.dice["下"] = R
        self.dice["左"] = D
        self.dice["右"] = U

    def west(self):
        U, D, L, R = [self.dice["上"], self.dice["下"], self.dice["左"], self.dice["右"]]
        self.dice["上"] = R
        self.dice["下"] = L
        self.dice["左"] = U
        self.dice["右"] = D

    def south(self):
        U, D, F, B = [self.dice["上"], self.dice["下"], self.dice["前"], self.dice["後"]]
        self.dice["上"] = B
        self.dice["前"] = U
        self.dice["下"] = F
        self.dice["後"] = D    
        
numbers = list(map(int, input().split()))
order_seq = list(input())

dice = Dice(numbers)
print(dice.order(order_seq))

Submission status: Accepted

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

Submission status: Accepted

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

class Dice:
    def __init__(self, num):
        self.state = {}
        for i in range(1,6+1):
            self.state[i] = num[i-1]
        
    def action(self, a):
        new_state = self.state.copy()
        if a=='E':
            new_state[1] = self.state[4]
            new_state[4] = self.state[6]
            new_state[6] = self.state[3]
            new_state[3] = self.state[1]
        elif a=='N':
            new_state[1] = self.state[2]
            new_state[2] = self.state[6]
            new_state[6] = self.state[5]
            new_state[5] = self.state[1]
        elif a=='S':
            new_state[1] = self.state[5]
            new_state[5] = self.state[6]
            new_state[6] = self.state[2]
            new_state[2] = self.state[1]
        elif a=='W':
            new_state[1] = self.state[3]
            new_state[3] = self.state[6]
            new_state[6] = self.state[4]
            new_state[4] = self.state[1]
        self.state = new_state
    
dice = Dice(num)
for a in A:
    dice.action(a)

print(dice.state[1])

Submission status: Accepted

Solution code:
a = [int(i) for i in input().split()]
dir = input()

class Dise:
    def __init__(self,a):
        self.dise = [0 for i in range(len(a))]
        for i in range(len(a)):
            self.dise[i] = a[i]

    def roll(self,dir):
        for self.pop_str in dir:
            if self.pop_str == "N":
                self.dise[0],self.dise[1],self.dise[4],self.dise[5] = self.dise[1],self.dise[5],self.dise[0],self.dise[4]
            elif self.pop_str == "S":
                self.dise[0],self.dise[1],self.dise[4],self.dise[5] = self.dise[4],self.dise[0],self.dise[5],self.dise[1]
            elif self.pop_str == "E":
                self.dise[0],self.dise[2],self.dise[3],self.dise[5] = self.dise[3],self.dise[0],self.dise[5],self.dise[2]
            elif self.pop_str == "W":
                self.dise[0],self.dise[2],self.dise[3],self.dise[5] = self.dise[2],self.dise[5],self.dise[0],self.dise[3]

    #確認用
    def output(self):
        print(self.dise[0])

dise = Dise(a)
dise.roll(dir)
dise.output()

Submission status: Accepted

Solution code:
class Dice(object):
    def __init__(self, nums):
        from collections import deque
        self.ns = deque([nums[4], nums[0], nums[1]])
        self.we = deque([nums[3], nums[0], nums[2]])
        self.bk = deque([nums[5]])

    def __str__(self):
        return str({"ns": self.ns, "we": self.we, "bk": self.bk})

    def operation(self, o):
        if o == "N":
            self.n()
        elif o == "S":
            self.s()
        elif o == "W":
            self.w()
        elif o == "E":
            self.e()
        else:
            raise BaseException("invalid", o)

    def n(self):
        self.ns.append(self.bk.popleft())
        self.bk.append(self.ns.popleft())
        self.we[1] = self.ns[1]

    def s(self):
        self.ns.appendleft(self.bk.pop())
        self.bk.appendleft(self.ns.pop())
        self.we[1] = self.ns[1]

    def w(self):
        self.we.append(self.bk.popleft())
        self.bk.append(self.we.popleft())
        self.ns[1] = self.we[1]

    def e(self):
        self.we.appendleft(self.bk.pop())
        self.bk.appendleft(self.we.pop())
        self.ns[1] = self.we[1]

    def get_top(self):
        return self.ns[1]


def resolve():
    nums = [int(i) for i in input().split()]
    ops = input()
    dc = Dice(nums)
    for o in ops:
        dc.operation(o)
    print(dc.get_top())


resolve()

Submission status: Accepted

Solution code:

#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, 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 print(self):
        '''print top of dice'''
        print(self.top)
    def north(self):
        self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
    def south(self):
        self.top, self.front, self.bottom, self.rear = \
            self.rear, self.top, self.front, self.bottom
    def east(self):
        self.top, self.right, self.bottom, self.left = \
            self.left, self.top, self.right, self.bottom
    def west(self):
        self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top

d = input().split()
dice = Dice(d[0], d[1], d[2], d[3], d[4], d[5])

commands = list(input())
for cmd in commands:
    if cmd == 'N':
        dice.north()
    elif cmd == 'S':
        dice.south()
    elif cmd == 'E':
        dice.east()
    elif cmd == 'W':
        dice.west()
    else:
        pass
dice.print()

Submission status: Accepted

Solution code:
from typing import List


class Dice():
    def __init__(self, lst):
        self.top = lst[0]
        self.front = lst[1]
        self.right = lst[2]
        self.left = lst[3]
        self.back = lst[4]
        self.bottom = lst[5]

    def rotate(self, direction):
        if direction == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        if direction == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        if direction == "S":
            self.top, self.front, self.bottom, self.back = self.back, self.top, self.front, self.bottom
        if direction == "W":
            self.top, self.left, self.bottom, self.right = self.right, self.top, self.left, self.bottom


def main():
    dice_nums: List[int] = list(map(int, input().split()))
    directions: str = input()

    dice = Dice(dice_nums)
    for direction in directions:
        dice.rotate(direction)
    print(dice.top)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,tb):
        self.table = tb
    def spin(self, dirc):
        directions = dirc
        table1 = self.table
        
        for direction in directions:
            res = [0]*6
            if direction == "N":
                #[1,2,4,8,16,32]
                #[2,32,4,8,1,16]
                res[0] = table1[1]
                res[1] = table1[5]
                res[2] = table1[2]
                res[3] = table1[3]
                res[4] = table1[0]
                res[5] = table1[4]
                
            elif direction == "S":
                #[1,2,4,8,16,32]
                #[16,1,4,8,32,2]
                res[0] = table1[4]
                res[1] = table1[0]
                res[2] = table1[2]
                res[3] = table1[3]
                res[4] = table1[5]
                res[5] = table1[1]
                
            elif direction == "E":
                #[1,2,4,8,16,32]
                #[8,2,1,32,16,4]
                res[0] = table1[3]
                res[1] = table1[1]
                res[2] = table1[0]
                res[3] = table1[5]
                res[4] = table1[4]
                res[5] = table1[2]

            elif direction == "W":
                res[0] = table1[2]
                res[1] = table1[1]
                res[2] = table1[5]
                res[3] = table1[0]
                res[4] = table1[4]
                res[5] = table1[3]
            
            table1 =  res
        self.table = table1
tb1 = list(map(int,input().split()))
directions = input()


dice1 = Dice(tb1)
dice1.spin(directions)
print(dice1.table[0])

Submission status: Accepted

Solution code:
dice=input().split()
process=input()

do = {'N': (2,6,3,4,1,5),'S': (5,1,3,4,6,2),'E':(4,2,1,6,5,3),'W': (3,2,6,1,5,4)}

for x in process:
    dice=[dice[y-1] for y in do[x]]
print(dice[0])

Submission status: Accepted

Solution code:
class Dice:
    top     = -1
    front   = -1
    right   = -1
    left    = -1
    back    = -1
    bottom  = -1
    
    def __init__(self, top, front, right, left, back, bottom):
        self.top, self.front, self.right, self.left, self.back, self.bottom = top, front, right, left, back, bottom
    
    def rolltoN(self):
        self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
    
    def rolltoS(self):
        self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
    
    def rolltoW(self):
        self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
    
    def rolltoE(self):
        self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
    
    def returntop(self):
        return self.top

a,b,c,d,e,f = map(int, input().split())
dice = Dice(a,b,c,d,e,f)
strorder = input()

for c in strorder:
    if c == 'N':
        dice.rolltoN()
    elif c == 'S':
        dice.rolltoS()
    elif c == 'W':
        dice.rolltoW()
    elif c == 'E':
        dice.rolltoE()
print(dice.returntop())

Submission status: Accepted

Solution code:
class Dice:
    
    def __init__(self, nums):
        self.nums = list(nums)
        
    @property
    def top(self):
        return self.nums[0]
        
    def _shift(self, *pairs):
        for pair in pairs:
            num = self.nums[pair[0]]
            self.nums[pair[0]] = self.nums[pair[1]]
            self.nums[pair[1]] = num
            
    def go(self, opes:str):
        for ope in opes:
            if ope == "N":
                self.go_north()
            elif ope == "E":
                self.go_east()
            elif ope == "W":
                self.go_west()
            else:
                self.go_south()
        
    def go_north(self):
        self._shift((0, 1), (1, 5), (5, 4))
        
    def go_east(self):
        self._shift((0, 3), (3, 5), (5, 2))
        
    def go_west(self):
        self._shift((0, 2), (2, 5), (5, 3))
        
    def go_south(self):
        self._shift((0, 4), (4, 5), (5, 1))
        

dice = Dice(map(int, input().split()))
dice.go(input())
print(dice.top)

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self):
        self.nums = list(range(6))
        self.work = list(range(6))

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

    def rotate(self, cmd):
        for i in range(6):
            # deepcopy
            self.work[i] = self.nums[i]

        if cmd == 'N':
            self.set_nums(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif cmd == 'S':
            self.set_nums(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1]),
        elif cmd == 'E':
            self.set_nums(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        else:
            self.set_nums(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

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

nums = [int(arg) for arg in input().split()]
d = Dice()
d.set_nums(*nums)
for cmd in list(input()):
    d.rotate(cmd)
print(d.top())

Submission status: Accepted

Solution code:
class Dice():
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    
    
    def diceMovement(self, step):
        self.step = step
        
        if self.step == 'E':
            temp = self.s1
            self.s1 = self.s4
            self.s4 = self.s6
            self.s6 = self.s3
            self.s3 = temp
            
            
        elif self.step == 'N':
            temp = self.s1
            self.s1 = self.s2
            self.s2 = self.s6
            self.s6 = self.s5
            self.s5 = temp
            
        elif self.step == 'S':
            temp = self.s1
            self.s1 = self.s5
            self.s5 = self.s6
            self.s6 = self.s2 
            self.s2 = temp
            
        else:
            temp = self.s1
            self.s1 = self.s3
            self.s3 = self.s6
            self.s6 = self.s4
            self.s4 = temp
            
            
            
    def getTop(self):
        return self.s1
        
        
def main():
    s1,s2,s3,s4,s5,s6 = map(int, input().split())
    dice = Dice(s1,s2,s3,s4,s5,s6)
    movement = str(input())
    
    for step in movement:
        dice.diceMovement(step)
        
    print(f'{dice.getTop()}')

if __name__ == '__main__': main()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.dice = [d1,d2,d3,d4,d5,d6]
    def turn(self,dir):
        if dir == 'S':
            self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
        if dir == 'N':
            self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
        if dir == 'W':
            self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
        if dir == 'E':
            self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]

dice_num = input().split()
direction = input()

init_Dice = Dice(dice_num[0],dice_num[1],dice_num[2],dice_num[3],dice_num[4],dice_num[5])
for a in range(len(direction)):
    init_Dice.turn(direction[a])
print(init_Dice.dice[0])

Submission status: Accepted

Solution code:
class Dice:
  __x = 1
  __y = 0
  def __init__(self,dice):
    self.dice = dice
    
  def output(self):
    print(self.dice[0])
    
  def move(self,str):
    if str == 'N':
      temp = self.dice[0]
      self.dice[0] = self.dice[1]
      self.dice[1] = self.dice[5]
      self.dice[5] = self.dice[4]
      self.dice[4] = temp
    elif str == 'S':
      temp = self.dice[0]
      self.dice[0] = self.dice[4]
      self.dice[4] = self.dice[5]
      self.dice[5] = self.dice[1]
      self.dice[1] = temp

    elif str == 'E':
      temp = self.dice[0]
      self.dice[0] = self.dice[3]
      self.dice[3] = self.dice[5]
      self.dice[5] = self.dice[2]
      self.dice[2] = temp
      
    elif str == 'W':
      temp = self.dice[0]
      self.dice[0] = self.dice[2]
      self.dice[2] = self.dice[5]
      self.dice[5] = self.dice[3]
      self.dice[3] = temp      
      
di = list(map(int,input().split()))
m = list(input())
di = Dice(di)
for i in m:
  di.move(i)
di.output()

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,label):
        self.W = label[3]
        self.S = label[1]
        self.E = label[2]
        self.N = label[4]
        self.u = label[0]
        self.l = label[5]
    def rotate(self,direction):
        if direction =='S':
            dummy = self.S
            self.S = self.u
            self.u = self.N
            self.N = self.l
            self.l = dummy
        elif direction == 'N':
            dummy = self.S
            self.S = self.l
            self.l = self.N
            self.N = self.u
            self.u = dummy
        elif direction == 'W':
            dummy = self.W
            self.W = self.u
            self.u = self.E
            self.E = self.l
            self.l = dummy
        else:
            dummy = self.W
            self.W = self.l
            self.l = self.E
            self.E = self.u
            self.u = dummy

D = Dice(input().split())
for i in input():
    D.rotate(i)
print(D.u)