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 Daise:
    def __init__(self, info_list):
        self.T = info_list[0]
        self.S = info_list[1]
        self.E = info_list[2]
        self.W = info_list[3]
        self.N = info_list[4]
        self.B = info_list[5]
    
    def change(self, axis):
        if axis == 'S':
            self.T, self.B, self.S, self.N = self.N, self.S, self.T, self.B
        
        elif axis == 'E':
            self.T, self.B, self.E, self.W = self.W, self.E, self.T, self.B
        
        elif axis == 'W':
            self.T, self.B, self.W, self.E = self.E, self.W, self.T, self.B
        
        elif axis == 'N':
            self.T, self.B, self.N, self.S = self.S, self.N, self.T, self.B


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

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

Solution (Python):
class Dice:

    def __init__(self):
        
        self.t = 1
        self.s = 2
        self.e = 4
        self.w = 8
        self.n = 16
        self.b = 32

    def __init__(self, t, s, e, w, n, b):
        
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b

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

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

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

if __name__ == '__main__':
    main()

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

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


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


if __name__ == '__main__':
    main()

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

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

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

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

for c in command:
    if (c == 'S'): 
        dice[1],dice[5],dice[4],dice[0] = dice[0],dice[1],dice[5],dice[4]
    elif(c == 'N'):
        dice[0],dice[1],dice[5],dice[4] = dice[1],dice[5],dice[4],dice[0]
    elif (c == 'W'): 
        dice[3], dice[5], dice[2],dice[0] = dice[0], dice[3], dice[5], dice[2]
    else:
        dice[0], dice[3], dice[5], dice[2] = dice[3], dice[5], dice[2],dice[0] 
print(dice[0])

Solution (Python):
"""
  1
4 2 3 5
  6
  
"""

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

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

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

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

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

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

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



buf = input().split(" ")
dice1 = Dice(int(buf[0]), int(buf[1]), int(buf[2]), int(buf[3]), int(buf[4]), int(buf[5]))

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

dice1.show_top()

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

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

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

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

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

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

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

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

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

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

Solution (Python):
from sys import stdin

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

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

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

Solution (Python):
from sys import stdin

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

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

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

Solution (Python):
from typing import List


class Dice:

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

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

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

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

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

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

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


data = [int(i) for i in input().split()]
order = list(input())



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

    
print(dice.get_upper_sursurface())

Solution (Python):
from typing import List


class Dice:

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

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

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

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

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

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

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



data = [int(i) for i in input().split()]
order = list(input())





dice = Dice(data)
for o in order:
    dice.invoke_method(o)
print(dice.get_upper_sursurface())

Solution (Python):
from typing import List


class Dice:

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

    def get_s(self) -> int:
        return self.s[0]

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

    def set_s(self, s0, s1, s2, s3, s4, s5) -> None:
        self.s[0] = s0
        self.s[1] = s1
        self.s[2] = s2
        self.s[3] = s3
        self.s[4] = s4
        self.s[5] = s5

    def S(self) -> None:
        self.set_s(self.s[4], self.s[0], self.s[2], self.s[3], self.s[5],
                   self.s[1])

    def N(self) -> None:
        self.set_s(self.s[1], self.s[5], self.s[2], self.s[3], self.s[0],
                   self.s[4])

    def E(self) -> None:
        self.set_s(self.s[3], self.s[1], self.s[0], self.s[5], self.s[4],
                   self.s[2])

    def W(self) -> None:
        self.set_s(self.s[2], self.s[1], self.s[5], self.s[0], self.s[4],
                   self.s[3])



data = [int(i) for i in input().split()]
order = list(input())





dice = Dice(data)
for o in order:
    dice.invoke_method(o)
print(dice.get_s())

Solution (Python):
class Dice:
	def __init__(self, ls):
		self.ls = ls
		self.now = 0
	
	def roll(self, direction):
		if direction == 'E': pat = [5, 2, 0, 3]
		elif direction == 'N': pat = [5, 4, 0, 1]
		elif direction == 'W': pat = [5, 3, 0, 2]
		elif direction == 'S': pat = [5, 1, 0, 4]

		tmp = self.ls[pat[0]]
		for i in range(4):
			try:
				self.ls[pat[i]] = self.ls[pat[i+1]]
			except(IndexError):
				pass
		self.ls[pat[-1]] = tmp
		
	def top(self):
		return self.ls[self.now]

dice = Dice(list(input().rstrip().split()))
for cmd in list(input().rstrip()):
	dice.roll(cmd)
print(dice.top())

Solution (Python):


class Dice:
    def __init__(self, top, s, e, w, n, bottom):
        self.top    = top
        self.s      = s
        self.e      = e
        self.w      = w
        self.n      = n
        self.bottom = bottom

    def rotate(self, dist):
        if dist == 'N':
            self.top, self.s, self.n, self.bottom = self.s, self.bottom, self.top, self.n 
        elif dist == 'S':
            self.s, self.bottom, self.top, self.n = self.top, self.s, self.n, self.bottom 
        elif dist == 'E':
            self.top, self.e, self.w, self.bottom = self.w, self.top, self.bottom, self.e 
        elif dist == 'W':
            self.w, self.top, self.bottom, self.e = self.top, self.e, self.w, self.bottom 

if __name__ == '__main__':
    num = map(int, raw_input().split())
    dice = Dice(*num)

    for c in raw_input():
        dice.rotate(c)
    print dice.top

Solution (Python):


label = list(map(int, input().split()))
command = list(input())

faces = [1, 2, 3, 4, 5, 6]


def dice(command):

    if command == "N":
        faces[0], faces[1], faces[4], faces[5] = faces[1], faces[5], faces[0], faces[4]

    elif command == "S":
        faces[0], faces[1], faces[4], faces[5] = faces[4], faces[0], faces[5], faces[1]

    elif command == "E":
        faces[0], faces[2], faces[3], faces[5] = faces[3], faces[0], faces[5], faces[2]

    else:  
        faces[0], faces[2], faces[3], faces[5] = faces[2], faces[5], faces[0], faces[3]


for c in command:
    dice(c)

print(label[faces[0] - 1])

Solution (Python):
d=list(map(int,input().split()))
o=[]
for i in input():
	o.append(i)
for i in range(len(o)):
	if o[i]=='N':
		d[0],d[1],d[4],d[5]=d[1],d[5],d[0],d[4]
	elif o[i]=='S':
		d[0],d[4],d[5],d[1]=d[4],d[5],d[1],d[0]
	elif o[i]=='E':
		d[0],d[3],d[5],d[2]=d[3],d[5],d[2],d[0]
	elif o[i]=='W':
		d[0],d[2],d[5],d[3]=d[2],d[5],d[3],d[0]
print(d[0])

Solution (Python):
class Dice:
    def __init__(self, eyes):
        self._eyes = eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        if direction == 'N':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[2]
            new[2] = old[6]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[1]
            new[6] = old[5]
            self._eyes = new
        elif direction == 'S':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[5]
            new[2] = old[1]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[6]
            new[6] = old[2]
            self._eyes = new
        elif direction == 'W':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[3]
            new[2] = old[2]
            new[3] = old[6]
            new[4] = old[1]
            new[5] = old[5]
            new[6] = old[4]
            self._eyes = new
        elif direction == 'E':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[4]
            new[2] = old[2]
            new[3] = old[1]
            new[4] = old[6]
            new[5] = old[5]
            new[6] = old[3]
            self._eyes = new
        else:
            raise ValueError('NEWS箱推し')


eyes = ['dummy'] + input().split()
dice = Dice(eyes)

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)

Solution (Python):
class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        if direction == 'N':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[2]
            new[2] = old[6]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[1]
            new[6] = old[5]
            self._eyes = new
        elif direction == 'S':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[5]
            new[2] = old[1]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[6]
            new[6] = old[2]
            self._eyes = new
        elif direction == 'W':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[3]
            new[2] = old[2]
            new[3] = old[6]
            new[4] = old[1]
            new[5] = old[5]
            new[6] = old[4]
            self._eyes = new
        elif direction == 'E':
            old = self._eyes
            new = ['dummy'] * 7
            new[1] = old[4]
            new[2] = old[2]
            new[3] = old[1]
            new[4] = old[6]
            new[5] = old[5]
            new[6] = old[3]
            self._eyes = new
        else:
            raise ValueError('NEWS箱推し')


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

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)

Solution (Python):
import copy


class Dice:
    def __init__(self, eyes):
        self._top = eyes[0]
        self._front = eyes[1]
        self._right = eyes[2]
        self._left = eyes[3]
        self._back = eyes[4]
        self._bottom = eyes[5]

    @property
    def eye(self):
        return self._top

    def roll(self, direction):
        old = copy.copy(self)
        if direction == 'N':
            self._top = old._front
            self._front = old._bottom
            self._back = old._top
            self._bottom = old._back
        elif direction == 'S':
            self._top = old._back
            self._front = old._top
            self._back = old._bottom
            self._bottom = old._front
        elif direction == 'W':
            self._top = old._right
            self._right = old._bottom
            self._left = old._top
            self._bottom = old._left
        elif direction == 'E':
            self._top = old._left
            self._right = old._top
            self._left = old._bottom
            self._bottom = old._right
        else:
            raise ValueError('NEWS箱推し')


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

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)

Solution (Python):
class dice:
    value = [0] * 6
    def __init__(self, list):
        self.value = list

    def dice_roll(self,dir):
        if dir == "S":
            prev = self.value
            self.value = [prev[4],prev[0],prev[2],prev[3],prev[5],prev[1]]
        elif dir == "N":
            prev = self.value
            self.value = [prev[1],prev[5],prev[2],prev[3],prev[0],prev[4]]
        elif dir == "W":
            prev = self.value
            self.value = [prev[2],prev[1],prev[5],prev[0],prev[4],prev[3]]
        elif dir == "E":
            prev = self.value
            self.value = [prev[3],prev[1],prev[0],prev[5],prev[4],prev[2]]

mydice = dice(list(map(int, input().split())))
x = str(input())
for i in x:
    mydice.dice_roll(i)
print(mydice.value[0])

Solution (Python):
class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        old = self._eyes
        new = ['dummy'] * 7
        if direction == 'N':
            new[1] = old[2]
            new[2] = old[6]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[1]
            new[6] = old[5]
        elif direction == 'S':
            new[1] = old[5]
            new[2] = old[1]
            new[3] = old[3]
            new[4] = old[4]
            new[5] = old[6]
            new[6] = old[2]
        elif direction == 'W':
            new[1] = old[3]
            new[2] = old[2]
            new[3] = old[6]
            new[4] = old[1]
            new[5] = old[5]
            new[6] = old[4]
        elif direction == 'E':
            new[1] = old[4]
            new[2] = old[2]
            new[3] = old[1]
            new[4] = old[6]
            new[5] = old[5]
            new[6] = old[3]
        else:
            raise ValueError('NEWS箱推し')
        self._eyes = new


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

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)

Solution (Python):
class Dice:
    def __init__(self, eyes):
        self._eyes = ['dummy'] + eyes

    @property
    def eye(self):
        return self._eyes[1]

    def roll(self, direction):
        a = self._eyes
        if direction == 'N':
            self._eyes = ['dummy', a[2], a[6], a[3], a[4], a[1], a[5]]
        elif direction == 'S':
            self._eyes = ['dummy', a[5], a[1], a[3], a[4], a[6], a[2]]
        elif direction == 'W':
            self._eyes = ['dummy', a[3], a[2], a[6], a[1], a[5], a[4]]
        elif direction == 'E':
            self._eyes = ['dummy', a[4], a[2], a[1], a[6], a[5], a[3]]
        else:
            raise ValueError('NEWS箱推し')


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

direction_text = input()
for d in direction_text:
    dice.roll(d)

print(dice.eye)

Solution (Python):
class Cube:
    def __init__(self, u, s, e, w, n, d):
        self.u = u
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.d = d

    def rotate(self, dic):
        if dic == "N":
            tmp = self.u
            self.u = self.s
            self.s = self.d
            self.d = self.n
            self.n = tmp
        elif dic == "E":
            tmp = self.u
            self.u = self.w
            self.w = self.d
            self.d = self.e
            self.e = tmp
        elif dic == "W":
            tmp = self.u
            self.u = self.e
            self.e = self.d
            self.d = self.w
            self.w = tmp
        else:
            tmp = self.u
            self.u = self.n
            self.n = self.d
            self.d = self.s
            self.s = tmp


def main():
    u, s, e, w, n, d = map(int, input().split())
    O = input()

    cube = Cube(u, s, e, w, n, d)
    for i in range(len(O)):
        cube.rotate(O[i])
    print(cube.u)


if __name__ == '__main__':
    main()

Solution (Python):



class dice ():
    def __init__(self, data):
        self.up = data[0]
        self.down = data[5]
        self.left = data[3]
        self.right =data[2]
        self.front = data[1]
        self.back = data[4]

    def turn_s(self):
        tmp = self.up
        self.up = self.back
        self.back = self.down
        self.down = self.front
        self.front = tmp

    def turn_n(self):
        tmp = self.up
        self.up = self.front
        self.front = self.down
        self.down = self.back
        self.back = tmp

    def turn_w(self):
        tmp = self.up
        self.up = self.right
        self.right = self.down
        self.down = self.left
        self.left = tmp

    def turn_e(self):
        tmp = self.up
        self.up = self.left
        self.left = self.down
        self.down = self.right
        self.right = tmp

    def turn(self, rotate="N"):
        if (rotate == "N"):
            self.turn_n()
        elif (rotate == "E"):
            self.turn_e()
        elif (rotate == "W"):
            self.turn_w()
        elif (rotate == "S"):
            self.turn_s()
        else:
            none

    def get_up(self):
        return self.up



dicedata = input().split()
orderdata = input()

newdice = dice(dicedata)

[newdice.turn(orderdata[idx]) for idx in range(0, len(orderdata))]

print(newdice.get_up())

Solution (Python):



class Dice() :

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

    def __init__(self, data):
        self.label = data

    def move(self, data):
        self.label = [self.label[idx] for idx in self.mask[data]]

    def get_up(self):
        return self.label[0]

dicedata = input().split()
orderdata = input()

newdice = Dice(dicedata)

[newdice.move(orderdata[idx]) for idx in range(0, len(orderdata))]

print(newdice.get_up())

Solution (Python):
def roll(l, command):
    '''
    return rolled list

    l : string list
    command: string
    '''
    res = []
    i = -1
    if command =='N':
        res = [l[i+2], l[i+6], l[i+3], l[i+4], l[i+1], l[i+5]]
    if command =='S':
        res = [l[i+5], l[i+1], l[i+3], l[i+4], l[i+6], l[i+2]]
    if command =='E':
        res = [l[i+4], l[i+2], l[i+1], l[i+6], l[i+5], l[i+3]]
    if command =='W':
        res = [l[i+3], l[i+2], l[i+6], l[i+1], l[i+5], l[i+4]]

    return res

faces = input().split()
commands = list(input())

for command in commands:
    faces = roll(faces, command)

print(faces[0])