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

Solution (Python):
class diceClass:
	def __init__(self, valuelist):
		self.valuelist = valuelist
		self.t = valuelist[0]
		self.b = valuelist[5]
		self.n = valuelist[4]
		self.s = valuelist[1]
		self.e = valuelist[2]
		self.w = valuelist[3]

	def throw(self, direction):
		
		if direction == 'N':
			self.t, self.s, self.b, self.n = self.s, self.b, self.n, self.t
		elif direction == 'S':
			self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b
		elif direction == 'W':
			self.t, self.e, self.b, self.w = self.e, self.b, self.w, self.t
		elif direction == 'E':
			self.t, self.e, self.b, self.w = self.w, self.t, self.e, self.b


arrinput = list(map(int, input().split()))
dirinput = input()
dice = diceClass(arrinput)
for s in dirinput:
	dice.throw(s)
print(dice.t)

Solution (Python):
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])

Solution (Python):
d = input().split()
cmd_list = list(input())
w = []

for cmd in cmd_list:
    if cmd == "E":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[3], w[1], w[0], w[5], w[4], w[2]
    elif cmd == "N":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[1], w[5], w[2], w[3], w[0], w[4]
    elif cmd == "S":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[4], w[0], w[2], w[3], w[5], w[1]
    elif cmd == "W":
        w = d
        d[0], d[1], d[2], d[3], d[4], d[5] = w[2], w[1], w[5], w[0], w[4], w[3]

print(d[0])

Solution (Python):
class Dice:
    def __init__(self, eye1, eye2, eye3, eye4, eye5, eye6):
        self.eye1 = eye1
        self.eye2 = eye2
        self.eye3 = eye3
        self.eye4 = eye4
        self.eye5 = eye5
        self.eye6 = eye6
    
    def N(self):
        self.eye1, self.eye2, self.eye6, self.eye5 = self.eye2, self.eye6, self.eye5, self.eye1
    def S(self):
        self.eye2, self.eye6, self.eye5, self.eye1 = self.eye1, self.eye2, self.eye6, self.eye5
    def E(self):
        self.eye1, self.eye3, self.eye6, self.eye4 = self.eye4, self.eye1, self.eye3, self.eye6
    def W(self):
        self.eye4, self.eye1, self.eye3, self.eye6 = self.eye1, self.eye3, self.eye6, self.eye4
    
    def print_top(self):
        print(self.eye1)


eye1, eye2, eye3, eye4, eye5, eye6 = map(int, input().split())
commands = input()
dice1 = Dice(eye1, eye2, eye3, eye4, eye5, eye6)
for command in commands:
    if command == 'N':
        dice1.N()
    elif command == 'S':
        dice1.S()
    elif command == 'E':
        dice1.E()
    else:
        dice1.W()

dice1.print_top()

Solution (Python):
dice = list(map(int,input().split()))
x = list(input())

def move(x):
    if x == "N":
        dice[0],dice[1],dice[2],dice[3],dice[4],dice[5] = dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]

    elif x == "W":
        dice[0],dice[1],dice[2],dice[3],dice[4],dice[5] = dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]

    elif x == "E":
        dice[0],dice[1],dice[2],dice[3],dice[4],dice[5] = dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]

    elif x == "S":
        dice[0],dice[1],dice[2],dice[3],dice[4],dice[5] = dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]

for i in range(len(x)):
    move(x[i])
print(dice[0])

Solution (Python):

class Dice:
    def __init__(self,a,b,c,d,e,f):
        self.face1 = a
        self.face2 = b
        self.face3 = c
        self.face4 = d
        self.face5 = e
        self.face6 = f

    def above_face(self):
        return self.face1

    def roll(self, order):
        if order == 'N':
            tmp = self.face1
            self.face1 = self.face2
            self.face2 = self.face6
            self.face6 = self.face5
            self.face5 = tmp
        elif order == 'S':
            tmp = self.face1
            self.face1 = self.face5
            self.face5 = self.face6
            self.face6 = self.face2
            self.face2 = tmp
        elif order == 'W':
            tmp = self.face1
            self.face1 = self.face3
            self.face3 = self.face6
            self.face6 = self.face4
            self.face4 = tmp
        else:
            tmp = self.face1
            self.face1 = self.face4
            self.face4 = self.face6
            self.face6 = self.face3
            self.face3 = tmp

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

l_order = list(input())
for i in range(len(l_order)):
    dice1.roll(l_order[i])

print(dice1.above_face())

Solution (Python):
a, b, c, d, e, f = map(int, input().split())
directions = [x for x in input()]


class Dice():
    def __init__(self, a, b, c, d, e, f):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

    def rotation(self, directions):
        for direction in directions:
            if direction == 'N':
                self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a
            if direction == 'S':
                self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
            if direction == 'E':
                self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
            if direction == 'W':
                self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
        return self


dice = Dice(a, b, c, d, e, f)
print(dice.rotation(directions).a)

Solution (Python):
class Dice():
    
    state = [0 for _ in range(6)]

    def __init__(self, dice_list):
        self.state[0] = dice_list[0]
        self.state[1] = dice_list[1]
        self.state[2] = dice_list[2]
        self.state[3] = dice_list[3]
        self.state[4] = dice_list[4]
        self.state[5] = dice_list[5]

    def north(self):
        tmp = self.state[0]
        self.state[0] = self.state[1]
        self.state[1] = self.state[5]
        self.state[5] = self.state[4]
        self.state[4] = tmp

    def west(self):
        tmp = self.state[0]
        self.state[0] = self.state[2]
        self.state[2] = self.state[5]
        self.state[5] = self.state[3]
        self.state[3] = tmp

    def south(self):
        tmp = self.state[0]
        self.state[0] = self.state[4]
        self.state[4] = self.state[5]
        self.state[5] = self.state[1]
        self.state[1] = tmp


    def east(self):
        tmp = self.state[0]
        self.state[0] = self.state[3]
        self.state[3] = self.state[5]
        self.state[5] = self.state[2]
        self.state[2] = tmp

    
if __name__ == '__main__':
    L = list(map(int, input().split()))
    actions = list(input())

    dice = Dice(L)

    for action in actions:
        if action == 'N':
            dice.north()

        if action == 'W':
            dice.west()

        if action == 'S':
            dice.south()

        if action == 'E':
            dice.east()

    print(dice.state[0])

Solution (Python):
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])

Solution (Python):
class Dice:
    def __init__(self,labels):
       self.stat =  labels
    
    def roll_E(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[3],self.stat[0],self.stat[5],self.stat[2]
        
    def roll_N(self):
        self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[1],self.stat[5],self.stat[4],self.stat[0]
        
    def roll_S(self):
        self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[4],self.stat[0],self.stat[1],self.stat[5]
        
    def roll_W(self):
        self.stat[0],self.stat[2],self.stat[5],self.stat[3] = self.stat[2],self.stat[5],self.stat[3],self.stat[0]
        
    def get_top(self):
        return self.stat[0]
        
dice = Dice(input().split())
commands = input()

for command in commands:
    if command == "E":
        dice.roll_E()
    elif command == "N":
        dice.roll_N()
    elif command == "S":
        dice.roll_S()
    elif command == "W":
        dice.roll_W()

print(dice.get_top())

Solution (Python):
SN=[5,1,2,6]
WE=[4,1,3,6]

def EWSN(d):
  global SN,WE
  if d == "S" :
    SN = SN[3:4] + SN[0:3]
    WE[3] = SN[3]
    WE[1] = SN[1]
  elif d == "N":
    SN = SN[1:4] + SN[0:1]
    WE[3] = SN[3]
    WE[1] = SN[1]
  elif d == "E":
    WE = WE[3:4] + WE[0:3]
    SN[3] = WE[3]
    SN[1] = WE[1]
  elif d == "W":
    WE = WE[1:4] + WE[0:1]
    SN[3] = WE[3]
    SN[1] = WE[1]

dice = list(map(int,input().split(" ")))
op = input()

for i in op:
  EWSN(i)
print(dice[SN[1] - 1])

Solution (Python):


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])
        else:
            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(dice.get_Top())

Solution (Python):
import copy

class Dice:
    def __init__(self,numbers): 
        self.numbers=numbers

    def movement(self,direction):
        tmp=copy.copy(self.numbers)
        if(direction=="E"):
            self.numbers[0]=tmp[3]
            self.numbers[2]=tmp[0]
            self.numbers[3]=tmp[5]
            self.numbers[5]=tmp[2]
        elif(direction=="S"):
            self.numbers[0]=tmp[4]
            self.numbers[1]=tmp[0]
            self.numbers[4]=tmp[5]
            self.numbers[5]=tmp[1]
        elif(direction=="W"):
            self.numbers[0]=tmp[2]
            self.numbers[2]=tmp[5]
            self.numbers[3]=tmp[0]
            self.numbers[5]=tmp[3]
        elif(direction=="N"):
            self.numbers[0]=tmp[1]
            self.numbers[1]=tmp[5]
            self.numbers[4]=tmp[0]
            self.numbers[5]=tmp[4]
    
    def top(self):
        return self.numbers[0]

numbers=list(map(int,input().split(" ")))
d=Dice(numbers)

comms=list(input())
for comm in comms:
    d.movement(comm)

print(d.top())

Solution (Python):
class Dice:
    def __init__(self, top, south, east, west, north, bottom):
        self.eyes = [top, south, east, west, north, bottom]


def roll_to_S(dice):
    eyes = dice.eyes

    return Dice(eyes[4], eyes[0], eyes[2], eyes[3], eyes[5], eyes[1])


def roll_to_N(dice):
    eyes = dice.eyes

    return Dice(eyes[1], eyes[5], eyes[2], eyes[3], eyes[0], eyes[4])


def roll_to_W(dice):
    eyes = dice.eyes

    return Dice(eyes[2], eyes[1], eyes[5], eyes[0], eyes[4], eyes[3])


def roll_to_E(dice):
    eyes = dice.eyes

    return Dice(eyes[3], eyes[1], eyes[0], eyes[5], eyes[4], eyes[2])


if __name__ == "__main__":
    eyes = list(map(int, input().split()))

    roll_directions = input()

    dice = Dice(*eyes)

    roll_function_table = {
        "S": roll_to_S,
        "N": roll_to_N,
        "W": roll_to_W,
        "E": roll_to_E
    }

    for roll_direction in roll_directions:
        dice = roll_function_table[roll_direction](dice)

    print(dice.eyes[0])

Solution (Python):
class dice:
    top = 1
    flont = 2
    right = 3
    def do_N(self):
        temp = self.flont
        self.flont = 7-self.top
        self.top = temp

    def do_S(self):
        temp = 7-self.flont
        self.flont = self.top
        self.top = temp

    def do_E(self):
        temp = self.top
        self.top = 7-self.right
        self.right = temp

    def do_W(self):
        temp = 7-self.top
        self.top = self.right
        self.right = temp

num1 = list(map(int, input().split()))
order1 = input()

dice1 = dice()
for i in range(len(order1)):
    if order1[i] == "N":
        dice1.do_N()
    elif order1[i] == "S":
        dice1.do_S()
    elif order1[i] == "E":
        dice1.do_E()
    elif order1[i] == "W":
        dice1.do_W()

print(str(num1[dice1.top-1]))

Solution (Python):
import enum
class Direction(enum.Enum):
    N = "N"
    E = "E"
    W = "W"
    S = "S"

    @classmethod
    def value_of(cls, value):
        return [v for v in cls if v.value == value][0]


class Dice:
    def __init__(self, *value_list):
        self.__value_list = list(value_list)

    def rotate(self, direction):
        l = self.__value_list
        if  direction == Direction.N:
            l[0],l[1],l[5],l[4] = l[1],l[5],l[4],l[0]
        elif  direction == Direction.E:
            l[0],l[2],l[5],l[3] = l[3],l[0],l[2],l[5]
        elif  direction == Direction.W:
            l[0],l[2],l[5],l[3] = l[2],l[5],l[3],l[0]
        elif  direction == Direction.S:
            l[0],l[1],l[5],l[4] = l[4],l[0],l[1],l[5]
        
    def top_value(self):
        return self.__value_list[0]


dice = Dice(*input().split())
for i in input():
    dice.rotate(Direction.value_of(i))
print(dice.top_value())

Solution (Python):

dice = input().split()
com = [c for c in input()]

rolling = {
    'E': [3, 1, 0, 5, 4, 2],
    'W': [2, 1, 5, 0, 4, 3],
    'S': [4, 0, 2, 3, 5, 1],
    'N': [1, 5, 2, 3, 0, 4]
}

for c in com:
    dice = [dice[i] for i in rolling[c]]

print(dice[0])

Solution (Python):
one, two, three, four, five, six = (int(x) for x in input().split())
move = input()
top = one
bottom = six
north = five
east = three
west = four
south = two

for i in range(len(move)):
    if move[i] == "N":
        top, north, bottom, south = south, top, north, bottom
    elif move[i] == "E":
        top, east, bottom, west = west, top, east, bottom
    elif move[i] == "W":
        top, east, bottom, west = east, bottom, west, top
    elif move[i] == "S":
        top, north, bottom, south = north, bottom, south, top

print(top)

Solution (Python):
class Dice():
    def __init__(self, number):
        self.number = number
        
    def S(self):
        temp = self.number
        self.number = [temp[4], temp[0], temp[2], temp[3], temp[5], temp[1]]
    
    def N(self):
        temp = self.number
        self.number = [temp[1], temp[5], temp[2], temp[3], temp[0], temp[4]]
        
    def E(self):
        temp = self.number
        self.number = [temp[3], temp[1], temp[0], temp[5], temp[4], temp[2]]
        
    def W(self):
        temp = self.number
        self.number = [temp[2], temp[1], temp[5], temp[0], temp[4], temp[3]]
        
    def order(self, str):
        for ch in str:
            if ch == "S":
                self.S()
            elif ch == "N":
                self.N()
            elif ch == "E":
                self.E()
            else:
                self.W()
                

number = list(map(int, input().split()))
order = input()

dice = Dice(number)
dice.order(order)
print(dice.number[0])

Solution (Python):
n = [int(n) for n in input().split()]
D = input()

class Dice():

    def __init__(self,faces):
        self.top = faces[0]
        self.south = faces[1]
        self.east = faces[2]
        self.west = faces[3]
        self.north = faces[4]
        self.bottom = faces[5]

    def rotate(self,d):

        if d == "N":
            tmp = self.top
            self.top = self.south
            self.south = self.bottom
            self.bottom = self.north
            self.north = tmp

        elif d == "S":
            tmp = self.top
            self.top = self.north
            self.north = self.bottom
            self.bottom = self.south
            self.south = tmp

        elif d == "E":
            tmp = self.top
            self.top = self.west
            self.west = self.bottom
            self.bottom = self.east
            self.east = tmp

        elif d == "W":
            tmp = self.top
            self.top = self.east
            self.east = self.bottom
            self.bottom = self.west
            self.west = tmp

    def get_top_value(self):
        return self.top


N = Dice(n)
for d in D:
    N.rotate(d)

print(N.get_top_value())

Solution (Python):
class Dice:
    def __init__(self, num):
        self.num = num
    def roll(self, fn):
        for i in range(len(fn)):
            if fn[i] == "S":
               ue = self.num[4]
               self.num[4] = self.num[5]
               self.num[5] = self.num[1]
               self.num[1] = self.num[0]
               self.num[0] = ue
            elif fn[i] == "N":
               ue = self.num[1]
               self.num[1] = self.num[5]
               self.num[5] = self.num[4]
               self.num[4] = self.num[0]
               self.num[0] = ue    
            elif fn[i] == "W":
               ue = self.num[2]
               self.num[2] = self.num[5]
               self.num[5] = self.num[3]
               self.num[3] = self.num[0]
               self.num[0] = ue
            elif fn[i] == "E":
               ue = self.num[3]
               self.num[3] = self.num[5]
               self.num[5] = self.num[2]
               self.num[2] = self.num[0]
               self.num[0] = ue     
num = list(map(int, input().split(" ")))
fn = str(input())
dice1 = Dice(num)
dice1.roll(fn)
print(num[0])

Solution (Python):

def Roll(c, lst) :
    if c == 'N' :
        lst[0], lst[1], lst[5], lst[4] = lst[1], lst[5], lst[4], lst[0]
    elif c == 'S' :
        lst[0], lst[1], lst[5], lst[4] = lst[4], lst[0], lst[1], lst[5]
    elif c == 'E' :
        lst[0], lst[2], lst[5], lst[3] = lst[3], lst[0], lst[2], lst[5]
    elif c == 'W' :
        lst[0], lst[2], lst[5], lst[3] = lst[2], lst[5], lst[3], lst[0]
    return lst
    

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

direction = list(input())
for i in range(len(direction)) :
    D = direction.pop(0)
    Roll(D, dice)


print(dice[0])

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

    def print_top(self):
        print(self.top)

    def roll(self, direction):
        if direction == 'S':
            self.south()
        elif direction == 'N':
            self.north()
        elif direction == 'E':
            self.east()
        elif direction == 'W':
            self.west()

    def north(self):
        [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]

    def south(self):
        [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]

    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]


labels = input().split()
directions = input()

dice = Dice(*labels)
for direction in directions:
    dice.roll(direction)
dice.print_top()

Solution (Python):
class Dice():
    def __init__(self, a, b, c, d, e, f):
        self.s = [0, a, b, c, d, e, f]

    def rotate(self, dir):
        if dir == "N":
            self.s[0] = self.s[1] 
            self.s[1] = self.s[2] 
            self.s[2] = self.s[6]
            self.s[6] = self.s[5]
            self.s[5] = self.s[0]
            return

        elif dir == "W":
            self.s[0] = self.s[1]
            self.s[1] = self.s[3] 
            self.s[3] = self.s[6]
            self.s[6] = self.s[4]
            self.s[4] = self.s[0]
            return

        elif dir == "S":
            self.s[0] = self.s[1]
            self.s[1] = self.s[5] 
            self.s[5] = self.s[6]
            self.s[6] = self.s[2]
            self.s[2] = self.s[0]
            return

        elif dir == "E":
            self.s[0] = self.s[1]
            self.s[1] = self.s[4] 
            self.s[4] = self.s[6]
            self.s[6] = self.s[3]
            self.s[3] = self.s[0]
            return

        else:
            return

dice = Dice(*list(map(int, input().split())))

for order in input():
    dice.rotate(order)

print(dice.s[1])

Solution (Python):
class Dice(object):
    def __init__(self, numbers: list):
        self.numbers = dict(zip(("T", "S", "E", "W", "N", "B"), numbers))

    def _roll(self, old_part: tuple):
        new_part = old_part[1:] + (old_part[0],)
        new_numbers = [self.numbers[face] for face in new_part]

        for old, new in zip(old_part, new_numbers):
            self.numbers[old] = new

    def vroll(self, reverse=False):
        """北方向に回転"""
        old_part = ("N", "T", "S", "B")
        self._roll(old_part if not reverse else old_part[::-1])

    def hroll(self, reverse=False):
        """時計回りに回転"""
        old_part = ("N", "W", "S", "E")
        self._roll(old_part if not reverse else old_part[::-1])

    def roll_to(self, direction: str):

        if direction == "N":
            self.vroll()
        elif direction == "S":
            self.vroll(reverse=True)
        elif direction == "E":
            self.hroll(reverse=True)
            self.vroll()
            self.hroll()
        elif direction == "W":
            self.hroll()
            self.vroll()
            self.hroll(reverse=True)
        else:
            raise AssertionError


dice = Dice(list(map(int, input().split())))
for direction in input():
    dice.roll_to(direction)
print(dice.numbers["T"])

Solution (Python):
class Dice:
    def __init__(self, one: int, two: int, three: int, four: int, five: int, six: int) -> None:
        self.__one = one
        self.__two = two
        self.__three = three
        self.__four = four
        self.__five = five
        self.__six = six

    def roll(self, direction) -> None:
        if direction == "N":
            tmp = self.__one
            self.__one = self.__two
            self.__two = self.__six
            self.__six = self.__five
            self.__five = tmp

        if direction == "E":
            tmp = self.__one
            self.__one = self.__four
            self.__four = self.__six
            self.__six = self.__three
            self.__three = tmp

        if direction == "S":
            tmp = self.__one
            self.__one = self.__five
            self.__five = self.__six
            self.__six = self.__two
            self.__two = tmp

        if direction == "W":
            tmp = self.__one
            self.__one = self.__three
            self.__three = self.__six
            self.__six = self.__four
            self.__four = tmp

    @property
    def one(self) -> int:
        return self.__one


if __name__ == "__main__":
    one, two, three, four, five, six = map(int, input().split(' '))
    dice = Dice(one, two, three, four, five, six)
    directions = list(input())
    for direction in directions:
        dice.roll(direction)
    print(dice.one)

Solution (Python):
class Dice(object):
    """
    入力を保持してサイコロを転がすと各面の値がどう変わるかをreturnする
    Attributes
    ----------
    stat : str
        上面を[0]、前面を[1]としたサイコロの側面の値
    Figure :
            4
            ↓
           _＿__
        ／0   ／|
    3→ |1￣ |2 |
        |＿＿|／
          ↑
          5
    """
    def __init__(self, all_num):
        self.stat = all_num
    def roll_N(self):
        self.stat[0],self.stat[1],self.stat[4],self.stat[5] = self.stat[1],self.stat[5],self.stat[0],self.stat[4]
    def roll_E(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[3],self.stat[0],self.stat[5],self.stat[2]
    def roll_S(self):
        self.stat[0],self.stat[1],self.stat[4],self.stat[5] = self.stat[4],self.stat[0],self.stat[5],self.stat[1]
    def roll_W(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[2],self.stat[5],self.stat[0],self.stat[3]
    def top(self):
        return self.stat[0]



dice = Dice(input().split())
orders = input()

for order in orders:
    if order == "N":
        dice.roll_N()
    elif order == "E":
        dice.roll_E()
    elif order == "S":
        dice.roll_S()
    elif order == "W":
        dice.roll_W()
print(dice.top())

Solution (Python):
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.face = {'head':1, 'tail':4, 'left':3, 'right':2, 'above':0, 'below':5}
    
    def roll(self, ch):
        dice = self.dice
        face = self.face
        if ch == 'S':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['above']]
            dice[face['above']] = dice[face['tail']]
            dice[face['tail']] = dice[face['below']]
            dice[face['below']] = tmp
        elif ch == 'N':
            tmp = dice[face['head']]
            dice[face['head']] = dice[face['below']]
            dice[face['below']] = dice[face['tail']]
            dice[face['tail']] = dice[face['above']]
            dice[face['above']] = tmp
        elif ch == 'W':
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['above']]
            dice[face['above']] = dice[face['right']]
            dice[face['right']] = dice[face['below']]
            dice[face['below']] = tmp
        else:
            tmp = dice[face['left']]
            dice[face['left']] = dice[face['below']]
            dice[face['below']] = dice[face['right']]
            dice[face['right']] = dice[face['above']]
            dice[face['above']] = tmp
    def top(self):
        dice = self.dice
        face = self.face
        return dice[face['above']]
dice = Dice([*map(int, input().split())])
for ch in input():
    dice.roll(ch)
print(dice.top())

Solution (Python):
roll_dict = dict(E = (3, 1, 0, 5, 4, 2), W = (2, 1, 5, 0, 4, 3), S = (4, 0, 2, 3, 5, 1), N = (1, 5, 2, 3, 0, 4))
dice = list(map(int, input().split()))
directions = input()

for i in directions:
  new_dice = []
  for j in range(6):
    new_dice.append(dice[ roll_dict[i][j] ])
  dice = new_dice

print(dice[0])

Solution (Python):



t, s, e, w, n, b = map(int, input().split())
process = list(input())


for p in process:
    tmp_t = t
    tmp_s = s
    tmp_e = e
    tmp_w = w
    tmp_n = n
    tmp_b = b

    if p=='S':
        s = tmp_t
        t = tmp_n
        n = tmp_b
        b = tmp_s
    elif p=='N':
        s = tmp_b
        n = tmp_t
        t = tmp_s
        b = tmp_n
    elif p=='W':
        w = tmp_t
        e = tmp_b
        t = tmp_e
        b = tmp_w
    elif p=='E':
        w = tmp_b
        e = tmp_t
        t = tmp_w
        b = tmp_e


print(t)

Solution (Python):
dice = input().rstrip().split(' ')
indication = str(input())
indic = list(indication)
length = len(indic)
for i in range(length):
  newdice = [0] * 6
  if str(indic[i]) == "N":
    newdice[0] = dice[1]
    newdice[1] = dice[5]
    newdice[2] = dice[2]
    newdice[3] = dice[3]
    newdice[4] = dice[0]
    newdice[5] = dice[4]
    dice = newdice
  elif str(indic[i]) == "S":
    newdice[0] = dice[4]
    newdice[1] = dice[0]
    newdice[2] = dice[2]
    newdice[3] = dice[3]
    newdice[4] = dice[5]
    newdice[5] = dice[1]
    dice = newdice
  elif str(indic[i]) == "E":
    newdice[0] = dice[3]
    newdice[1] = dice[1]
    newdice[2] = dice[0]
    newdice[3] = dice[5]
    newdice[4] = dice[4]
    newdice[5] = dice[2]
    dice = newdice
  elif str(indic[i]) == "W":
    newdice[0] = dice[2]
    newdice[1] = dice[1]
    newdice[2] = dice[5]
    newdice[3] = dice[0]
    newdice[4] = dice[4]
    newdice[5] = dice[3]
    dice = newdice

print(int(dice[0]))

Solution (Python):
class dice():
    def __init__(self,a,b,c,d,e,f):
        self.l=[a,b,c,d,e,f]
    def move(self,direc):
        if direc=="N":
            self.l=[self.l[1],self.l[5],self.l[2],self.l[3],self.l[0],self.l[4]]
        elif direc=="S":
            self.l=[self.l[4],self.l[0],self.l[2],self.l[3],self.l[5],self.l[1]]
        if direc=="E":
            self.l=[self.l[3],self.l[1],self.l[0],self.l[5],self.l[4],self.l[2]]
        if direc=="W":
            self.l=[self.l[2],self.l[1],self.l[5],self.l[0],self.l[4],self.l[3]]
A,B,C,D,E,F=map(int,input().split())
dice_=dice(A,B,C,D,E,F)
s=input()
for i in s:
    dice_.move(i)
print(dice_.l[0])

Solution (Python):
class Dice:
    def __init__(self, lst):
        self.a = lst[0]
        self.b = lst[1]
        self.c = lst[2]
        self.d = lst[3]
        self.e = lst[4]
        self.f = lst[5]
        
    def roll(self, orders):
        for order in orders:
            if order=='W':
                tmp = self.a
                self.a = self.c
                self.c = self.f
                self.f = self.d
                self.d = tmp
            elif order=='E':
                tmp = self.a
                self.a = self.d
                self.d = self.f
                self.f = self.c
                self.c = tmp
            elif order=='S':
                tmp = self.a
                self.a = self.e
                self.e = self.f
                self.f = self.b
                self.b = tmp
            elif order=='N':
                tmp = self.a
                self.a = self.b
                self.b = self.f
                self.f = self.e
                self.e = tmp

        print(self.a)
                

if __name__ == '__main__':
    lst = [int(x) for x in input().split()]
    orders = input()
    
    dice = Dice(lst)
    dice.roll(orders)