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 dice():
    
    def __init__(self,a,b,c,d,e,f):
        self.A=[a,b,c,d,e,f]
        self.temp=[]
        
    def N_method(self):
       for i in self.A:
        self.temp.append(i)       


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

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

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

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


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

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

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

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

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

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

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

if __name__ == '__main__':

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

	d = Dice()

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

	print(dd[d.get_top()])

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

Solution (Python):
houkou={'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)}
saikoro=input().split()
for i in input():
  saikoro=[saikoro[j]for j in houkou[i]]
  
print(saikoro[0])

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

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


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

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

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

print(l[0])

Solution (Python):



class Dice:
    def __init__(self, num):
        self.num = num
        
    def show(self):
        """ 出目を表示する """
        print(self.num[0])
        
    def roll(self, direction):
        """ NSEWへ転がしたときの処理 """
        new_num = []
        if direction == "N":
            data = [1, 5, 2, 3, 0, 4]
        elif direction == "S":
            data = [4, 0, 2, 3, 5, 1]
        elif direction == "E":
            data = [3, 1, 0, 5, 4, 2]
        elif direction == "W":
            data = [2, 1, 5, 0, 4, 3]
        for i in data:
            new_num.append(self.num[i])
        self.num = new_num
        
dice_num = list(map(int, input().split()))
dice_roll = input()

dice1 = Dice(dice_num)

for direction in dice_roll:
    dice1.roll(direction)
dice1.show()

Solution (Python):
dice=input().split()
for direction in input():
    if direction == "N":
        dice=[dice[i]for i in [1,5,2,3,0,4]]
    elif direction == "W":
        dice=[dice[i]for i in [2,1,5,0,4,3]] 
    elif direction == "E":
        dice=[dice[i]for i in [3,1,0,5,4,2]] 
    elif direction == "S":
        dice=[dice[i]for i in [4,0,2,3,5,1]]
    
print(dice[0])

Solution (Python):
def north(list):
    List = []
    List.append(list[1])
    List.append(list[5])
    List.append(list[2])
    List.append(list[3])
    List.append(list[0])
    List.append(list[4])
    return List
 
def west(list):
    List = []
    List.append(list[2])
    List.append(list[1])
    List.append(list[5])
    List.append(list[0])
    List.append(list[4])
    List.append(list[3])
    return List
     
def south(list):
    List = []
    List.append(list[4])
    List.append(list[0])
    List.append(list[2])
    List.append(list[3])
    List.append(list[5])
    List.append(list[1])
    return List
 
def east(list):
    List = []
    List.append(list[3])
    List.append(list[1])
    List.append(list[0])
    List.append(list[5])
    List.append(list[4])
    List.append(list[2])
    return List
 
dice = list(map(int, input().split()))
x = str(input())
y = list(x)
for i in range(len(x)):
    if y[i] == 'N':
        dice[0:5] = north(dice)
    elif y[i] == 'W':
        dice[0:5] = west(dice)
    elif y[i] == 'S':
        dice[0:5] = south(dice)
    elif y[i] == 'E':
        dice[0:5] = east(dice)
print(dice[0])

Solution (Python):
class Dice():
    def __init__(self,rot,Face):
        self.rot= rot
        self.Face = Face
    def Rotate(rot,Face):
        r=len(rot)
        intFace=[int(Face[i]) for i in range(6)]

        for i in range(r):
            Temp=[intFace[i] for i in range(6)]

            if rot[i]== "E":
                intFace[0]=Temp[3]
                intFace[1]=Temp[1]
                intFace[2]=Temp[0]
                intFace[3]=Temp[5]
                intFace[4]=Temp[4]
                intFace[5]=Temp[2]

            elif rot[i]== "W":
                intFace[0]=Temp[2]
                intFace[1]=Temp[1]
                intFace[2]=Temp[5]
                intFace[3]=Temp[0]
                intFace[4]=Temp[4]
                intFace[5]=Temp[3]

            elif rot[i]== "N":
                intFace[0]=Temp[1]
                intFace[1]=Temp[5]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[0]
                intFace[5]=Temp[4]


            elif rot[i]== "S":
                intFace[0]=Temp[4]
                intFace[1]=Temp[0]
                intFace[2]=Temp[2]
                intFace[3]=Temp[3]
                intFace[4]=Temp[5]
                intFace[5]=Temp[1]


        return intFace


Face = input().split()
rot=input()
dice=Dice(rot,Face)
finFace= Dice.Rotate(rot,Face)
print(finFace[0])

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

    def set_number(self, d0, d1, d2, d3, d4, d5):
        self.number[0] = d0
        self.number[1] = d1
        self.number[2] = d2
        self.number[3] = d3
        self.number[4] = d4
        self.number[5] = d5

    def roll(self, command):
        if   command == "E":
            self.set_number(self.number[3],self.number[1],self.number[0],self.number[5],self.number[4],self.number[2])
        elif command == "N":
            self.set_number(self.number[1],self.number[5],self.number[2],self.number[3],self.number[0],self.number[4])
        elif command == "S":
            self.set_number(self.number[4],self.number[0],self.number[2],self.number[3],self.number[5],self.number[1])
        elif command == "W":
            self.set_number(self.number[2],self.number[1],self.number[5],self.number[0],self.number[4],self.number[3])
        else:
            raise

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




list_face = list(map(int, input().split()))
commands = input()

dice = Dice()
dice.set_number(list_face[0], list_face[1], list_face[2], list_face[3], list_face[4], list_face[5])

for command in commands:
    dice.roll(command)

print(dice.get_top())

Solution (Python):
def S(dice):
    a_0=dice[0]
    a_1=dice[1]
    a_4=dice[4]
    a_5=dice[5]
    dice[1]=a_0
    dice[5]=a_1
    dice[4]=a_5
    dice[0]=a_4

def N(dice):
    a_0=dice[0]
    a_1=dice[1]
    a_4=dice[4]
    a_5=dice[5]
    dice[1]=a_5
    dice[5]=a_4
    dice[4]=a_0
    dice[0]=a_1

def W(dice):
    a_0=dice[0]
    a_3=dice[3]
    a_5=dice[5]
    a_2=dice[2]
    dice[0]=a_2
    dice[3]=a_0
    dice[5]=a_3
    dice[2]=a_5

def E(dice):
    a_0=dice[0]
    a_3=dice[3]
    a_5=dice[5]
    a_2=dice[2]
    dice[0]=a_3
    dice[3]=a_5
    dice[5]=a_2
    dice[2]=a_0

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

for i in command:
    if i=='S':
        S(dice)
    elif i=='N':
        N(dice)
    elif i=='W':
        W(dice)
    elif i=='E':
        E(dice)
print(dice[0])

Solution (Python):

class Dice :
    
    def __init__(self, dice) :
        self.dice = dice
    
    def roll(self, direction):
        tmp = self.dice[:]
        if direction == "N":
            self.dice[0] = tmp[1]
            self.dice[1] = tmp[5]
            self.dice[4] = tmp[0]
            self.dice[5] = tmp[4]
        elif direction == "E":
            self.dice[0] = tmp[3]
            self.dice[2] = tmp[0]
            self.dice[3] = tmp[5]
            self.dice[5] = tmp[2]
        elif direction == "W":
            self.dice[0] = tmp[2]
            self.dice[2] = tmp[5]
            self.dice[3] = tmp[0]
            self.dice[5] = tmp[3]
        else:
            self.dice[0] = tmp[4]
            self.dice[1] = tmp[0]
            self.dice[4] = tmp[5]
            self.dice[5] = tmp[1]
            
    def dice_show(self):
        print(self.dice[0])

dice = Dice(list(map(str, input().split())))

for dire in list(input()):
    dice.roll(dire)
    
dice.dice_show()

Solution (Python):
class Dice:
    N = [0, 1, 5, 4]
    S = N[::-1]
    E = [0, 3, 5, 2]
    W = E[::-1]

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

    def toX(self, x):
        data = getattr(self, x)
        self.numbers.append(0)
        for k in range(5):
            i1 = data[k - 1] if k != 0 else 6
            i2 = data[k] if k != 4 else 6
            self.numbers[i1] = self.numbers[i2]
        del self.numbers[6]

dice = Dice([int(i) for i in input().split()])
[dice.toX(d) for d in input()]
print(dice.numbers[0])

Solution (Python):
face = list(map(int, input().split()))
order = input()

for j in range(len(order)) :
  if(order[j] == "S") :
    key = face[4]
    face[4] = face[5]
    face[5] = face[1]
    face[1] = face[0]
    face[0] = key
  elif(order[j] == "N") :
    key = face[1]
    face[1] = face[5]
    face[5] = face[4]
    face[4] = face[0]
    face[0] = key
  elif(order[j] == "E") :
    key = face[3]
    face[3] = face[5]
    face[5] = face[2]
    face[2] = face[0]
    face[0] = key
  else :
    key = face[2]
    face[2] = face[5]
    face[5] = face[3]
    face[3] = face[0]
    face[0] = key

print(face[0])

Solution (Python):
from enum import Enum
import sys
import math


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()))

Solution (Python):
def dice(dice_num,direction):
	for s in direction:
		tmp = dice_num
		if s == "S":
			dice_num = [tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]	
		elif s == "E":
			dice_num = [tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
		elif s == "N":
			dice_num = [tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]
		elif s == "W":
			dice_num = [tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
	return(dice_num[0])

if __name__ == '__main__':
	dice_num = [int(s) for s in input().split()]
	direction = input()

	print(dice(dice_num,direction))

Solution (Python):
class Dice:
    def __init__(self):
        self.number = [i for i in range(6)]
        self.tmp = [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 next(self,direction):
        for i in range(6):
            self.tmp[i] = self.number[i]

        if direction == 'E':
            self.setNumber(self.tmp[3], self.tmp[1], self.tmp[0], self.tmp[5], self.tmp[4], self.tmp[2])
        elif direction == 'N':
            self.setNumber(self.tmp[1], self.tmp[5], self.tmp[2], self.tmp[3], self.tmp[0], self.tmp[4])
        elif direction == 'S':
            self.setNumber(self.tmp[4], self.tmp[0], self.tmp[2], self.tmp[3], self.tmp[5], self.tmp[1])
        elif direction == 'W':
            self.setNumber(self.tmp[2], self.tmp[1], self.tmp[5], self.tmp[0], self.tmp[4], self.tmp[3])
    def get_result(self):
        return self.number[0]

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

for str in dire_str:
    dice.next(str)

print(dice.get_result())

Solution (Python):
class Dice(object):
    def __init__(self, labels):
        self.stat = labels

    def roll_e(self):
        self.stat[0], self.stat[2], self.stat[5], self.stat[3] = self.stat[3], self.stat[0], self.stat[2], 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 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 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 == "W":
        dice.roll_w()
    elif command == "N":
        dice.roll_n()
    elif command == "S":
        dice.roll_s()
print(dice.get_top())

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

    def roll(self, axis, count=1):
        while count < 0:
            count += 4
        if axis == "X":
            for _ in range(count):
                self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif axis == "Y":
            for _ in range(count):
                self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif axis == "Z":
            for _ in range(count):
                self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        elif axis == "N":
            self.roll("X", 1)
        elif axis == "W":
            self.roll("Y", -1)
        elif axis == "S":
            self.roll("X", -1)
        elif axis == "E":
            self.roll("Y", 1)


labels = [int(c) for c in input().split()]
operations = input()
d = Dice(labels)
for o in operations:
    d.roll(o)
print(d.top)

Solution (Python):
cube = list(map(int, input().split()))
a = input()
for i in a:
    if i == 'N':
        cube = [cube[1],cube[5],cube[2],cube[3],cube[0],cube[4]]
    if i == 'E':
        cube = [cube[3],cube[1],cube[0],cube[5],cube[4],cube[2]]
    if i == 'W':
        cube = [cube[2],cube[1],cube[5],cube[0],cube[4],cube[3]]
    if i == 'S':
        cube = [cube[4],cube[0],cube[2],cube[3],cube[5],cube[1]]
print(cube[0])

Solution (Python):



def initDice(numbers): 
    
    dice = {'top': numbers[0], 'bottom': numbers[5], 'front': numbers[1],
            'back': numbers[4], 'right': numbers[2], 'left': numbers[3]}
    return dice

def rollDice(dice, direction): 
    dice = dice
    if direction == 'N':
        top = dice['front']
        bottom = dice['back']
        front = dice['bottom']
        back = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'S':
        top = dice['back']
        bottom = dice['front']
        front = dice['top']
        back = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['front'] = front
        dice['back'] = back
    elif direction == 'E':
        top = dice['left']
        bottom = dice['right']
        right = dice['top']
        left = dice['bottom']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    elif direction == 'W':
        top = dice['right']
        bottom = dice['left']
        right = dice['bottom']
        left = dice['top']
        dice['top'] = top
        dice['bottom'] = bottom
        dice['right'] = right
        dice['left'] = left
    return dice

numbers = [int(i) for i in input().split()]
dice = initDice(numbers)
directions = input()
for direction in directions:
  dice = rollDice(dice, direction)

print(dice['top'])

Solution (Python):
class Dice():
  def __init__ (self):
    
    self.position = [0,0,0,0,0,0]
  
  def setNumber (self, num):
    for i,x in enumerate(num):
      self.position[i] = x
    
      
  def roll(self, roll):
    for i in range(len(roll)):
      s = roll[i:i+1]
      p = self.position
      if s == 'E':
        self.setNumber([p[3], p[1], p[0], p[5], p[4], p[2]])
        
      elif s == 'W':
        self.setNumber([p[2], p[1], p[5], p[0], p[4], p[3]])
        
      elif s == 'S':
        self.setNumber([p[4], p[0], p[2], p[3], p[5], p[1]])
        
      elif s == 'N':
        self.setNumber([p[1], p[5], p[2], p[3], p[0], p[4]])
        

  def printTop(self):
    print(self.position[0])

d = Dice()

n = list(int(x) for x in input().split())
d.setNumber(n)

r = str(input())

d.roll(r)

d.printTop()

Solution (Python):
class Dice:
    def __init__(self,my_label):
        self.top,self.front,self.right,self.left,self.back,self.bottom = [int(x) for x in my_label]

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

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

        
        
numbers = [int(x) for x in input().split(" ")]
commands = [str(c) for c in input()]

my_label = numbers
dice = Dice(my_label)

for c in commands:
    dice.Roll(c)

dice.Open()

Solution (Python):
class dice:
    def __init__(self, t, S, E):
        self.dice = list(map(int, input().split()))
        self.t = t
        self.S = S
        self.E = E
        self.now_dice()
    
    def roll(self, order):
        if order == 'E':
            self.t, self.E = self.W, self.t
        elif order == 'N':
            self.t, self.S = self.S, self.g
        elif order == 'S':
            self.t, self.S = self.N, self.t
        elif order == 'W':
            self.t, self.E = self.E, self.g
        self.now_dice()
    
    def now_dice(self):
        self.N = 7 - self.S
        self.g = 7 - self.t
        self.W = 7 - self.E
        self.now = [self.t, self.S, self.E, self.N, self.W, self.g]
        return self.now

if __name__ == '__main__':
    dice = dice(1, 2, 3)
    order = list(input())
    for v in order:
        dice.roll(v)
    print(dice.dice[dice.t-1])

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

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])
        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()))

Solution (Python):
class Dice:
    def __init__(self, numbers):
        self.numbers = numbers
        self.number_dict = {1:numbers[0], 2:numbers[1], 3:numbers[2], -3:numbers[3], -2:numbers[4], -1: numbers[5]}
        self.top = 1
        self.front = 2
        self.right = 3

    def move(self, direction):
        if direction == 'N':
            self.top, self.front = self.front, -self.top
        elif direction == 'S':
            self.top, self.front = -self.front, self.top
        elif direction == 'E':
            self.top, self.right = -self.right, self.top
        else:
            self.top, self.right = self.right, -self.top

    def show_number(self):
        print(self.number_dict[self.top])

dice = Dice(list(map(int, input().split())))
move_cmd = input()
for char in move_cmd:
    dice.move(char)
dice.show_number()

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

Solution (Python):
d=list(map(int,input().split()))
t=[d[i] for i in [0,1,5,4]]
y=[d[i] for i in [0,2,5,3]]

for i in input():
    if i == 'N' or i=='S':
        if i=='S':
            t.insert(0,t.pop())
        else:
            t.append(t.pop(0))
        y[0],y[2]=t[0],t[2]
    if i == 'W' or i=='E':
        if i=='E':
            y.insert(0,y.pop())
        else:
            y.append(y.pop(0))
        t[0],t[2]=y[0],y[2]
print(t[0])

Solution (Python):
class Dice:
    def __init__(self, labels):
        self.labels = labels
        
    def __str__(self):
        return str(self.labels[0])
    
    def roll_south(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[4], self.labels[0], self.labels[1], self.labels[5]
            
    def roll_east(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[3], self.labels[0], self.labels[2], self.labels[5]
    
    def roll_west(self):
        self.labels[0], self.labels[3], self.labels[5], self.labels[2] = self.labels[2], self.labels[0], self.labels[3], self.labels[5]
    
    def roll_north(self):
        self.labels[0], self.labels[4], self.labels[5], self.labels[1] = self.labels[1], self.labels[0], self.labels[4], self.labels[5]
        
def main():
    labels = list(map(int, input().split()))
    orders = input()
    d = Dice(labels)
    for o in orders:
        if o == 'S':
            d.roll_south()
        elif o == 'E':
            d.roll_east()
        elif o == 'W':
            d.roll_west()
        elif o == 'N':
            d.roll_north()
    print(d)
    
main()

Solution (Python):
class Dice:
    def __init__(self):
        self.number = [0]*6
        self.work = [0]*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 lotate(self,st):
        for i in range(len(self.number)):
            self.work[i] = self.number[i]  
        if st == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        if st == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        if st == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
        if st == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])

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


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

dice = Dice()
dice.setNumber(s[0],s[1],s[2],s[3],s[4],s[5])

request = input()       
for w in request:       
    dice.lotate(w)

result = dice.top()
print(result)

Solution (Python):
class Dice:
  def __init__(self, m1, m2, m3, m4, m5, m6):
    self.m1 = m1
    self.m2 = m2
    self.m3 = m3
    self.m4 = m4
    self.m5 = m5
    self.m6 = m6

  def moveDice(self, dir):
    if dir == 'S':
      self.m1, self.m2, self.m6, self.m5 = self.m5, self.m1, self.m2, self.m6
    elif dir == 'N':
      self.m1, self.m2, self.m6, self.m5 = self.m2, self.m6, self.m5, self.m1
    elif dir == 'E':
      self.m1, self.m4, self.m6, self.m3 = self.m4, self.m6, self.m3, self.m1
    elif dir == 'W':
      self.m1, self.m3, self.m6, self.m4 = self.m3, self.m6, self.m4, self.m1

n1, n2, n3, n4, n5, n6 = map(int, input().split())
direct = input()

dice1 = Dice(n1, n2, n3, n4, n5, n6)
for i in range(len(direct)):
  dice1.moveDice(direct[i])

print(dice1.m1)

Solution (Python):
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    
    def set(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 kaiten(self,m):
        for i in range(6):
            self.work[i] = self.number[i]
        if m == 'E':
            self.set(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif m == 'N':
            self.set(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif m == 'S':
            self.set(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif m == 'W':
            self.set(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def top(self):
        return self.number[0]
    
a = Dice()
table = list(map(int,input().split()))
a.set(table[0], table[1], table[2], table[3], table[4], table[5])

m = str(input())
for i in m:
    a.kaiten(i)
    
print("%d"%(a.top()))