Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice I

  Write a program to simulate rolling a dice, which can be constructed by the following net.

  As shown in the figures, each face is identified by a different label from 1 to 6.

  Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.

Input

  In the first line, six integers assigned to faces are given in ascending order of their corresponding labels.

  In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.

Output

  Print the integer which appears on the top face after the simulation.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

$0 \leq $ the length of the command $\leq 100$

Sample Input 1

1 2 4 8 16 32
SE

Sample Output 1

8

You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.

Sample Input 2

1 2 4 8 16 32
EESWN

Sample Output 2

32



Sample input:
1 2 4 8 16 32
SE


Sample output:
8

Submission status: Accepted

Solution code:
import math
def main():
    dice = Dice([int(a) for a in input().split()])
    commands = input()
    for d in range(len(commands)):
        dice.move(commands[d])
    dice.show()

class Dice():
    def __init__(self, surface):
        self.l = surface
 
    def move(self, dir):
        if(dir == 'N'):
            self.l = [self.l[1], self.l[5], self.l[2], self.l[3], self.l[0], self.l[4]]
        elif(dir == 'W'):
            self.l = [self.l[2], self.l[1], self.l[5], self.l[0], self.l[4], self.l[3]]
        elif(dir == 'E'):
            self.l = [self.l[3], self.l[1], self.l[0], self.l[5], self.l[4], self.l[2]]
        elif(dir == 'S'):
            self.l = [self.l[4], self.l[0], self.l[2], self.l[3], self.l[5], self.l[1]]

    def show(self):
        print(self.l[0])


main()

Submission status: Accepted

Solution code:
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/11/ITP1_11_A


class Dice(object):
    def __init__(self, top, front, right, left, back, bottom):
        self.t = top
        self.f = front
        self.r = right
        self.l = left
        self.bc = back
        self.bt = bottom

    def roll(self, direction):
        if direction == 'N':
            self.t, self.f, self.bt, self.bc = self.f, self.bt, self.bc, self.t
        elif direction == 'S':
            self.t, self.f, self.bt, self.bc = self.bc, self.t, self.f, self.bt
        elif direction == 'E':
            self.t, self.l, self.bt, self.r = self.l, self.bt, self.r, self.t
        elif direction == 'W':
            self.t, self.l, self.bt, self.r = self.r, self.t, self.l, self.bt

    def show_top(self):
        print(self.t)

    def __str__(self):
        # top, front, right, left, back, bottom
        return f'{self.t}, {self.f}, {self.r}, {self.l}, {self.bc}, {self.bt}'


def solve():
    dice = Dice(*input().split())

    for direction in input():
        dice.roll(direction)
    dice.show_top()


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# Dice I
# 2018/11/17

class Dice:
    def __init__(self, *num):
        if len(num) != 6:
            raise ValueError("6!")
        self.numbers = num

    def east(self):
        index = (3, 1, 0, 5, 4, 2)
        self.numbers = tuple((self.numbers[i] for i in index))

    def west(self):
        index = (2, 1, 5, 0, 4, 3)
        self.numbers = tuple((self.numbers[i] for i in index))

    def south(self):
        index = (4, 0, 2, 3, 5, 1)
        self.numbers = tuple((self.numbers[i] for i in index))

    def north(self):
        index = (1, 5, 2, 3, 0, 4)
        self.numbers = tuple((self.numbers[i] for i in index))

    @property
    def top(self):
        return self.numbers[0]

    def __repr__(self):
        return "Dice(" + ", ".join([str(i) for i in self.numbers]) + ")"


def main():
    num = [int(i) for i in input().rstrip().split()]
    dice = Dice(*num)
    for i in input().rstrip():
        if i == "E":
            dice.east()
        elif i == "W":
            dice.west()
        elif i == "S":
            dice.south()
        elif i == "N":
            dice.north()
    print(dice.top)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


class Dice:
    diceNum = []
    pos = 0
    def setNum(self,i):
        self.pos = i[0]
        self.diceNum.append(i[0])
        self.diceNum.append(i[2])
        self.diceNum.append(i[5])
        self.diceNum.append(i[3])
        self.diceNum.append(i[4])
        self.diceNum.append(i[1])
    def showPos(self):
        print (self.pos)
    def move(self,d):
        if (d == "E"):
            i0=self.diceNum[3]
            i1=self.diceNum[0] 
            i2=self.diceNum[1] 
            i3=self.diceNum[2]
            i4=self.diceNum[4]
            i5=self.diceNum[5]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
            self.pos = self.diceNum[0]
        if (d == "W"):
            i0=self.diceNum[1]
            i1=self.diceNum[2] 
            i2=self.diceNum[3] 
            i3=self.diceNum[0]
            i4=self.diceNum[4]
            i5=self.diceNum[5]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
            self.pos = self.diceNum[0]
        if (d == "S"):
            i0=self.diceNum[4]
            i1=self.diceNum[1] 
            i2=self.diceNum[5] 
            i3=self.diceNum[3]
            i4=self.diceNum[2]
            i5=self.diceNum[0]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
            self.pos = self.diceNum[0]
        if (d == "N"):
            i0=self.diceNum[5]
            i1=self.diceNum[1] 
            i2=self.diceNum[4] 
            i3=self.diceNum[3]
            i4=self.diceNum[0]
            i5=self.diceNum[2]
            self.diceNum =[i0,i1,i2,i3,i4,i5]
            self.pos= self.diceNum[0]

l = list(map(int,input().split()))
dice = Dice()
dice.setNum(l)
for i in str(input()):
    dice.move(i)
dice.showPos()

Submission status: Accepted

Solution code:
d=input().split()
v=list(input())

def roll(Dice,Vector):
    if Vector == "N":
        c=Dice[0]
        Dice[0]=Dice[1]
        Dice[1]=Dice[5]
        Dice[5]=Dice[4]
        Dice[4]=c
    elif Vector == "W":
        c=Dice[0]
        Dice[0]=Dice[2]
        Dice[2]=Dice[5]
        Dice[5]=Dice[3]
        Dice[3]=c
    elif Vector == "E":
        c=Dice[0]
        Dice[0]=Dice[3]
        Dice[3]=Dice[5]
        Dice[5]=Dice[2]
        Dice[2]=c
    elif Vector == "S":
        c=Dice[0]
        Dice[0]=Dice[4]
        Dice[4]=Dice[5]
        Dice[5]=Dice[1]
        Dice[1]=c

for item in v:
    roll(d,item)
print(d[0])

Submission status: Accepted

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

for s in slist:
    if s == "N":
        next = list("263415")
    elif s == "E":
        next = list("421653")
    elif s == "S":
        next = list("513462")
    else:
        next = list("326154")

    tmp = [0] * 6
    for i, n in enumerate(next):
        tmp[i] = dice[int(n)-1]

    dice = tmp

print(dice[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def swap(dice,i,j,k,l):#diceの目をi→ｊ→ｋ→ｌ→iの順に入れ替える
    x=dice[l]
    dice[l]=dice[k]
    dice[k]=dice[j]
    dice[j]=dice[i]
    dice[i]=x
    return dice


dice=list(map(int,input().split()))
Dice=[0]
dice=Dice +dice
roll=list(input())
for i in range(0,len(roll)):
    if(roll[i]=="S"):
        dice=swap(dice,1,2,6,5)
    elif(roll[i]=="E"):
        dice=swap(dice,1,3,6,4)
    elif(roll[i]=="W"):
        dice=swap(dice,1,4,6,3)
    elif(roll[i]=="N"):
        dice=swap(dice,1,5,6,2)
print(dice[1])

Submission status: Accepted

Solution code:
from collections import OrderedDict
d = list(map(int, input().split()))
command = input()
p = OrderedDict()
for k, v in zip(["T", "N", "S", "E", "W", "B"], [d[0], d[4], d[1], d[2], d[3], d[5]]):
    p[k] = v

for c in command:
    t, n, s, e, w, b = p["T"], p["N"], p["S"], p["E"], p["W"], p["B"]
    if c == "N":
        p["N"], p["T"], p["S"], p["B"]= t, s, b, n
    if c == "S":
        p["N"], p["T"], p["S"], p["B"]= b, n, t, s
    if c == "E":
        p["E"], p["T"], p["W"], p["B"]= t, w, b, e
    if c == "W":
        p["E"], p["T"], p["W"], p["B"]= b, e, t, w
    
print(p["T"])

Submission status: Accepted

Solution code:
a,b,c,d,e,f=list(map(int,input().split()))
for g in input():
 if g=='N':a,e,f,b=b,a,e,f
 if g=='E':a,c,f,d=d,a,c,f
 if g=='W':a,c,f,d=c,f,d,a
 if g=='S':a,e,f,b=e,f,b,a
print(a)

Submission status: Accepted

Solution code:
num = input().split()
r = input()

for i in r:
    temp = num[0]
    if (i == 'W'): 
        num[0] = num[2]
        num[2] = num[5]
        num[5] = num[3]
        num[3] = temp
    elif (i == 'E'):
        num[0] = num[3]
        num[3] = num[5]
        num[5] = num[2]
        num[2] = temp
    elif (i == 'S'):
        num[0] = num[4]
        num[4] = num[5]
        num[5] = num[1]
        num[1] = temp
    else :
        num[0] = num[1]
        num[1] = num[5]
        num[5] = num[4]
        num[4] = temp

print(num[0])

Submission status: Accepted

Solution code:
dice = list(map(int, input().split()))
dir = list(input())
newdice = [0]*6

for i in dir:
    if i == 'N':
        newdice[0] = dice[1]
        newdice[1] = dice[5]
        newdice[5] = dice[4]
        newdice[4] = dice[0]
        newdice[2] = dice[2]
        newdice[3] = dice[3]

    elif i == 'E':
        newdice[0] = dice[3]
        newdice[3] = dice[5]
        newdice[5] = dice[2]
        newdice[2] = dice[0]
        newdice[1] = dice[1]
        newdice[4] = dice[4]
    elif i == 'S':
        newdice[0] = dice[4]
        newdice[4] = dice[5]
        newdice[5] = dice[1]
        newdice[1] = dice[0]
        newdice[2] = dice[2]
        newdice[3] = dice[3]
    else:
        newdice[0] = dice[2]
        newdice[2] = dice[5]
        newdice[5] = dice[3]
        newdice[3] = dice[0]
        newdice[1] = dice[1]
        newdice[4] = dice[4]

    dice = newdice[:]

print(dice[0])

Submission status: Accepted

Solution code:
class Dice:
    def __init__(self,dice):
        self.dice = dice
    def n_roll(self):
        self.dice = [self.dice[1],self.dice[5],self.dice[2],self.dice[3],self.dice[0],self.dice[4]]
    def s_roll(self):
        self.dice = [self.dice[4],self.dice[0],self.dice[2],self.dice[3],self.dice[5],self.dice[1]]
    def e_roll(self):
        self.dice = [self.dice[3],self.dice[1],self.dice[0],self.dice[5],self.dice[4],self.dice[2]]
    def w_roll(self):
        self.dice = [self.dice[2],self.dice[1],self.dice[5],self.dice[0],self.dice[4],self.dice[3]]
dice = list(map(int, input().split()))
dice1 = Dice(dice)
s = input()
for i in s:
    if i == "N":
        dice1.n_roll()
    elif i == "S":
        dice1.s_roll()
    elif i == "E":
        dice1.e_roll()
    elif i == "W":
        dice1.w_roll()
print(dice1.dice[0])

Submission status: Accepted

Solution code:
faces = {'N': (1, 5, 2, 3, 0, 4),
        'E': (3, 1, 0, 5, 4, 2),
        'S': (4, 0, 2, 3, 5, 1),
        'W': (2, 1, 5, 0, 4, 3)
        }
dice = list(map(int, input().split()))
face = input()
for f in face:
    dice = [dice[i] for i in faces[f]]
print(dice[0])

Submission status: Accepted

Solution code:
lab = list(map(int,input().split()))
dir = str(input())

for i in range(len(dir)):
    dcopy = lab.copy()
    if dir[i] == 'E':
        lab[0]=dcopy[3]
        lab[2]=dcopy[0]
        lab[3]=dcopy[5]
        lab[5]=dcopy[2]
    elif dir[i] == 'N':
        lab[0]=dcopy[1]
        lab[1]=dcopy[5]
        lab[4]=dcopy[0]
        lab[5]=dcopy[4]
    elif dir[i] == 'S':
        lab[0]=dcopy[4]
        lab[1]=dcopy[0]
        lab[4]=dcopy[5]
        lab[5]=dcopy[1]
    else:
        lab[0]=dcopy[2]
        lab[2]=dcopy[5]
        lab[3]=dcopy[0]
        lab[5]=dcopy[3]
print(lab[0])

Submission status: Accepted

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

#print(D)
s=input()
for i in range(len(s)):
    if s[i]=="E":
        E=[D[3],D[1],D[0],D[5],D[4],D[2]]
        D=E
    elif s[i]=="W":
        W=[D[2],D[1],D[5],D[0],D[4],D[3]]
        D=W
    elif s[i]=="S":
        S=[D[4],D[0],D[2],D[3],D[5],D[1]]
        D=S
    elif s[i]=="N":
        N=[D[1],D[5],D[2],D[3],D[0],D[4]]
        D=N
print(D[0])

Submission status: Accepted

Solution code:
result = 0

dice = input().split()

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

shaked = input()

for s in shaked:
    temp = dice[:]
    for f, t in moves[s]:
        temp[t - 1] = dice[f - 1]
    dice = temp[:]

print(dice[0])

Submission status: Accepted

Solution code:
class MIGI_HIDARI():

    def __init__(self,up,down,ue,shita,migi,hidari,value):
        self.up = up
        self.down = down
        self.ue = ue
        self.shita = shita
        self.migi = migi
        self.hidari = hidari
        self.value = value

    def MIGI(self):
        self.value = self.up
        self.up = self.hidari
        self.hidari = self.down
        self.down = self.migi
        self.migi = self.value


    def SHITA(self):
        self.value = self.up
        self.up = self.ue
        self.ue = self.down
        self.down = self.shita
        self.shita = self.value

    def HIDARI(self):
        self.value = self.up
        self.up = self.migi
        self.migi = self.down
        self.down = self.hidari
        self.hidari = self.value

    def UE(self):
        self.value = self.up
        self.up = self.shita
        self.shita = self.down
        self.down = self.ue
        self.ue = self.value

nums = input().rstrip().split(' ')

up = int(nums[0])
shita = int(nums[1])
migi = int(nums[2])
hidari = int(nums[3])
ue = int(nums[4])
down = int(nums[5])
value = ue

EWSN = list(input())

migi_hidari = MIGI_HIDARI(up,down,ue,shita,migi,hidari,value)

for i in EWSN:
    if i =="E":
        migi_hidari.MIGI()
    elif i =="W":
        migi_hidari.HIDARI()
    elif i =="S":
        migi_hidari.SHITA()
    else:
        migi_hidari.UE()
print(migi_hidari.up)

Submission status: Accepted

Solution code:
class Dice:
  def __init__(self, top=1, front=2, left=4, right=3, back=5, bottom=6):
    self.d = {"TOP":top, "FRONT":front, "LEFT":left, "RIGHT":right, "BACK":back, "BOTTOM":bottom}

  def roll_x(self):
    self._roll("TOP", "FRONT", "BOTTOM", "BACK")
  
  def roll_y(self):
    self._roll("FRONT", "LEFT", "BACK", "RIGHT")
  
  def roll_z(self):
    self._roll("TOP", "LEFT", "BOTTOM", "RIGHT")
  
  def _roll(self, a, b, c, d):
    self.d[a], self.d[b], self.d[c], self.d[d] = \
    self.d[b], self.d[c], self.d[d], self.d[a]

n = list(map(int, input().split()))
q = input()
d = Dice(n[0], n[1], n[3], n[2], n[4], n[5])
for ele in q:
  if ele=="N":
    d.roll_x()
  elif ele=="S":
    for _ in range(3):
      d.roll_x()
  elif ele=="E":
    d.roll_z()
  elif ele=="W":
    for _ in range(3):
      d.roll_z()
print(d.d["TOP"])

Submission status: Accepted

Solution code:
class Dice:
	def __init__(self, nums):
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
nums = [int(i) for i in input().split(' ')]
di = Dice(nums)
for op in input():
	if op == 'N': di.goN()
	elif op == 'E': di.goE()
	elif op == 'W': di.goW()
	elif op == 'S': di.goS()
print(di.cU)

Submission status: Runtime Error

Solution code:
class Dice(object):
 
    def __init__(self, d):

        self.rows = [d[0], d[4], d[5], d[1]]
        self.cols = [d[0], d[2], d[5], d[3]]
 
    def move_next_rows(self):
        temp = self.rows.pop(0)
        self.rows.append(temp)
        self.__update(self.cols, self.rows)

    def move_prev_rows(self):
        temp = self.rows.pop(3)
        self.rows.insert(0, temp)
        self.__update(self.cols, self.rows)
    
    def move_next_cols(self):
        temp = self.cols.pop(0)
        self.cols.append(temp)
        self.__update(self.rows, self.cols)
 
    def move_prev_cols(self):
        temp = self.cols.pop(3)
        self.cols.insert(0, temp)
        self.__update(self.rows, self.cols)

    def __update(self, x, y):
        x[0] = y[0]
        x[2] = y[2]
 
class DiceChecker(object):

    def __init__(self, dice1, dice2):
        self.dice1 = dice1
        self.dice2 = dice2
        self.dice1_top = self.dice1.rows[0]
        self.dice1_front = self.dice1.rows[3]
        
    def check_same_dice(self):

        is_same = False
        for _ in range(4):
            for _ in range(4):
                is_same_element = self.dice1.rows == self.dice2.rows and self.dice1.cols == self.dice2.cols
                if is_same_element:
                    is_same = True
                    break
                self.dice2.move_next_cols()
            else:     
                self.dice2.move_next_rows()
                continue
            break
        if is_same:
            print("Yes")
        else:
            print("No")
    
    def __find_num(self, x, dice):
        i = 0
        while x != dice.rows[0]:
            dice.move_next_rows()
            if i > 3:
                dice.move_next_cols()
                i = 0
            i+=1
    
    def __rot(self, dice):
        temp = dice.rows[1]
        dice.rows[1] = dice.rows[3]
        dice.rows[3] = temp

        temp = dice.cols[1]
        dice.cols[1] = dice.cols[3]
        dice.cols[3] = temp

        
d1 = list(map(int, input().split(" ")))
d2 = list(map(int, input().split(" ")))
dice1 = Dice(d1)
dice2 = Dice(d2)

dice_checker = DiceChecker(dice1, dice2)
dice_checker.check_same_dice()

Submission status: Runtime Error

Solution code:
c1=[int(i) for i in input().split()]
c2=[int(i) for i in input().split()]
d=[(0,0,1),(-1,0,0),(0,1,0),(0,-1,0),(1,0,0),(0,0,-1)]
def crosspro(y,x):
    return (y[1]*x[2]-y[2]*x[1],y[2]*x[0]-y[0]*x[2],y[0]*x[1]-y[1]*x[0])
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
def left(r):
    res=[]
    for p in r:
        res.append((p[1],-p[0],p[2]))
    return res
def right(r):
    res=[]
    for p in r:
        res.append((-p[1],p[0],p[2]))
    return res
T=["","N","E","W","S","NN"]
U=["","L","LL","LLL"]
def change(S):
    D=d
    for i in S:
        if i=="N":
            D=north(D)
        elif i=="E":
            D=east(D)
        elif i=="W":
            D=west(D)
        elif i=="S":
            D=south(D)
        elif i=="L":
            D=left(D)
        else:
            D=right(D)
    return D
for i in T:
    for j in U:
        D=change(i+j)
        flag=0
        for x in range(6):
            for y in range(6):
                if d[x]==D[y]:
                    if c1[x]!=c2[y]:
                        flag=1
        if flag==0:
            print("Yes")
            exit()
print("No")

Submission status: Runtime Error

Solution code:
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(

Submission status: Runtime Error

Solution code:
## サイコロ

d1, d2, d3, d4, d5, d6 = input().split()

dice = {
    '1': d1,
    '2': d2,
    '3': d3,
    '4': d4,
    '5': d5,
    '6': d6
}

spin_dict = {
    '1' : {
        's' : '6', #上
        'n' : '2', #下
        'e' : '4', #左
        'w' : '3', #右
    },
    '2' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '4', #左
        'w' : '3', #右
    },
    '3' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '2', #左
        'w' : '5', #右
    },
    '4' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '5', #左
        'w' : '2', #右
    },
    '5' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '3', #左
        'w' : '4', #右
    },
    '6' : {
        's' : '2', #上
        'n' : '1', #下
        'e' : '4', #左
        'w' : '3', #右
    },
}

spins = input().split()

num = '1'
for direction in spins:
    num = spin_dict[num][direction]

print(dice['num'])

Submission status: Runtime Error

Solution code:
## サイコロ

d1, d2, d3, d4, d5, d6 = input().split()

dice = {
    '1': d1,
    '2': d2,
    '3': d3,
    '4': d4,
    '5': d5,
    '6': d6
}

spin_dict = {
    '1' : {
        's' : '6', #上
        'n' : '2', #下
        'e' : '4', #左
        'w' : '3', #右
    },
    '2' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '4', #左
        'w' : '3', #右
    },
    '3' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '2', #左
        'w' : '5', #右
    },
    '4' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '5', #左
        'w' : '2', #右
    },
    '5' : {
        's' : '1', #上
        'n' : '6', #下
        'e' : '3', #左
        'w' : '4', #右
    },
    '6' : {
        's' : '2', #上
        'n' : '1', #下
        'e' : '4', #左
        'w' : '3', #右
    },
}

spins = input()

num = '1'
for direction in spins:
    num = spin_dict[num][direction]

print(dice[num])

Submission status: Runtime Error

Solution code:
class Dice():
        def __init__(self,data):
                self.number = data

        def rota_S(self):
                self.number[0],self.number[1],self.number[5],self.number[4] = self.number[1],self.$
        def rota_E(self):
                self.number[0],self.number[2],self.number[5],self.number[3] = self.number[2],self.$
        def rota_W(self):
                self.number[0],self.number[3],self.number[5],self.number[2] = self.number[3],self.$
        def rota_N(self):
                self.number[0],self.number[4],self.number[5],self.number[1] = self.number[4],self.$

        def get_top(self):
                return self.number[0]
data = list(map(int,input().split()))
opt = input()

mydice = Dice(data)
print(mydice.number)
for c in range(len(opt)):
        print(opt[c])
        if(opt[c] == "S"):      mydice.rota_S()
        elif(opt[c] == "E"):    mydice.rota_E()
        elif(opt[c] == "W"):     mydice.rota_W()
        elif(opt[c] == "N"):     mydice.rota_N()
        else: print("something error")
print(mydice.get_top())

Submission status: Runtime Error

Solution code:

  GNU nano 2.9.3                                                                                       a.py                                                                                                 

class Dice():
        def __init__(self,data):
                self.number = data

        def rota_S(self):
                self.number[0],self.number[1],self.number[5],self.number[4] = self.number[1],self.number[5],self.number[4],self.number[0]
        def rota_E(self):
                self.number[0],self.number[2],self.number[5],self.number[3] = self.number[2],self.number[5],self.number[3],self.number[0]
        def rota_W(self):
                self.number[0],self.number[3],self.number[5],self.number[2] = self.number[3],self.number[5],self.number[2],self.number[0]
        def rota_N(self):
                self.number[0],self.number[4],self.number[5],self.number[1] = self.number[4],self.number[5],self.number[1],self.number[0]

        def get_top(self):
                return self.number[0]
data = list(map(int,input().split()))
opt = input()

mydice = Dice(data)
print(mydice.number)
for c in range(len(opt)):
        print(opt[c])
        if(opt[c] == "S"):      mydice.rota_S()
        elif(opt[c] == "E"):    mydice.rota_E()
        elif(opt[c] == "W"):     mydice.rota_W()
        elif(opt[c] == "N"):     mydice.rota_N()
        else: print("something error")
print(mydice.get_top())

Submission status: Runtime Error

Solution code:
class Dice(object):
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom
    def rollN(self):
        prevN = self.north
        prevB = self.bottom
        prevS = self.south
        self.north = self.top
        self.bottom = prevN
        self.south = prevB
        self.top = prevS
    def rollS(self):
        prevS = self.south
        prevB = self.bottom
        prevN = self.north
        self.south = top
        self.bottom = prevS
        self.north = prevB
        self.top = prevN
    def rollE(self):
        prevE = self.east
        prevB = self.bottom
        prevW = self.west
        self.east = self.top
        self.bottom = prevE
        self.west = prevB
        self.top = prevW
    def rollW(self):
        prevW = self.west
        prevB = self.bottom
        prevE = self.east
        self.west = top
        self.bottom = prevW
        self.east = prevB
        self.top = prevE

diceInit = [int(n) for n in raw_input().split][:6:]
instruction = raw_input()

diceI = Dice(diceInit[0], diceInit[1], diceInit[2], diceInit[3], diceInit[4], diceInit[5])

for item in instruction:
    if item == 'N':
        diceI.rollN()
    elif item == 'E':
        diceI.rollE()
    elif item == 'W':
        diceI.rollW()
    elif item == 'S':
        diceI.rollS()

print diceI.top

Submission status: Runtime Error

Solution code:
class Dice(object):
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom
    def rollN(self):
        prevN = self.north
        prevB = self.bottom
        prevS = self.south
        self.north = self.top
        self.bottom = prevN
        self.south = prevB
        self.top = prevS
    def rollS(self):
        prevS = self.south
        prevB = self.bottom
        prevN = self.north
        self.south = top
        self.bottom = prevS
        self.north = prevB
        self.top = prevN
    def rollE(self):
        prevE = self.east
        prevB = self.bottom
        prevW = self.west
        self.east = self.top
        self.bottom = prevE
        self.west = prevB
        self.top = prevW
    def rollW(self):
        prevW = self.west
        prevB = self.bottom
        prevE = self.east
        self.west = top
        self.bottom = prevW
        self.east = prevB
        self.top = prevE

diceInit = [int(n) for n in raw_input().split()][:6:]
instruction = raw_input()

diceI = Dice(diceInit[0], diceInit[1], diceInit[2], diceInit[3], diceInit[4], diceInit[5])

for item in instruction:
    if item == 'N':
        diceI.rollN()
    elif item == 'E':
        diceI.rollE()
    elif item == 'W':
        diceI.rollW()
    elif item == 'S':
        diceI.rollS()

print diceI.top

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, data):
        self.data = data

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

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


dice = Dice.Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
print(dice.getTop())

Submission status: Runtime Error

Solution code:
class Dice:                                                                                                                           
    def __init__(self, data):
        self.data = data


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


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

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])

print(dice.getTop())