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: Runtime Error

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

class dice():
 def __init__(self, dice):
  self.dice = dice
 def S():
  one = self.dice[4]
  two = self.dice[0]
  five = self.dice[5]
  six = self.dice[1]
  InsSN(one, two, five, six)

 def InsSN(one, two, five, six):
  self.dice[0] = one
  self.dice[1] = two
  self.dice[4] = five
  self.dice[5] = six

 def N():
  one = self.dice[1]
  two = self.dice[5]
  five = self.dice[0]
  six = self.dice[4]
  InsSN(one, two, five, six)
  
 def InsWE(one, three, four, six):
  self.dice[0] = one
  self.dice[2] = three
  self.dice[4] = four
  self.dice[5] = six
 
 def W():
  one = self.dice[2]
  three = self.dice[5]
  four = self.dice[0]
  six = self.dice[3]
  InsWE(one, three, four, six)

 def E():
  one = self.dice[3]
  three = self.dice[0]
  four = self.dice[5]
  six = self.dice[2]
  InsWE(one, three, four, six)

di = dice(a)

for i in range(len(O)):
 if O[i] == 'S':
  di.S()
 elif O[i] == 'N':
  di.N()
 elif O[i] == 'E':
  di.E()
 elif O[i] == 'W':
  di.W()

print(di.dice[0])

Submission status: Runtime Error

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

class Dice():
 def __init__(self, d):
  self.dice = d
 def S():
  one = self.dice[4]
  two = self.dice[0]
  five = self.dice[5]
  six = self.dice[1]
  InsSN(one, two, five, six)

 def InsSN(one, two, five, six):
  self.dice[0] = one
  self.dice[1] = two
  self.dice[4] = five
  self.dice[5] = six

 def N():
  one = self.dice[1]
  two = self.dice[5]
  five = self.dice[0]
  six = self.dice[4]
  InsSN(one, two, five, six)
  
 def InsWE(one, three, four, six):
  self.dice[0] = one
  self.dice[2] = three
  self.dice[4] = four
  self.dice[5] = six
 
 def W():
  one = self.dice[2]
  three = self.dice[5]
  four = self.dice[0]
  six = self.dice[3]
  InsWE(one, three, four, six)

 def E():
  one = self.dice[3]
  three = self.dice[0]
  four = self.dice[5]
  six = self.dice[2]
  InsWE(one, three, four, six)

di = Dice(a)

for i in range(len(O)):
 if O[i] == 'S':
  di.S()
 elif O[i] == 'N':
  di.N()
 elif O[i] == 'E':
  di.E()
 elif O[i] == 'W':
  di.W()

print(di.dice[0])

Submission status: Runtime Error

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

class Dice():
 def __init__(self, d):
  self.dice = d
 def S(self):
  one = self.dice[4]
  two = self.dice[0]
  five = self.dice[5]
  six = self.dice[1]
  InsSN(one, two, five, six)

 def InsSN(self, one, two, five, six):
  self.dice[0] = one
  self.dice[1] = two
  self.dice[4] = five
  self.dice[5] = six

 def N(self):
  one = self.dice[1]
  two = self.dice[5]
  five = self.dice[0]
  six = self.dice[4]
  InsSN(one, two, five, six)
  
 def InsWE(self, one, three, four, six):
  self.dice[0] = one
  self.dice[2] = three
  self.dice[4] = four
  self.dice[5] = six
 
 def W(self):
  one = self.dice[2]
  three = self.dice[5]
  four = self.dice[0]
  six = self.dice[3]
  InsWE(one, three, four, six)

 def E(self):
  one = self.dice[3]
  three = self.dice[0]
  four = self.dice[5]
  six = self.dice[2]
  InsWE(one, three, four, six)

di = Dice(a)

for i in range(len(O)):
 if O[i] == 'S':
  di.S()
 elif O[i] == 'N':
  di.N()
 elif O[i] == 'E':
  di.E()
 elif O[i] == 'W':
  di.W()

print(di.dice[0])

Submission status: Runtime Error

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

class Dice():
 def __init__(self, d):
  self.dice = d
 def S(self):
  one = self.dice[4]
  two = self.dice[0]
  five = self.dice[5]
  six = self.dice[1]
  InsSN(one, two, five, six)

 def InsSN(self, one, two, five, six):
  self.dice[0] = one
  self.dice[1] = two
  self.dice[4] = five
  self.dice[5] = six

 def N(self):
  one = self.dice[1]
  two = self.dice[5]
  five = self.dice[0]
  six = self.dice[4]
  InsSN(one, two, five, six)
  
 def InsWE(self, one, three, four, six):
  self.dice[0] = one
  self.dice[2] = three
  self.dice[4] = four
  self.dice[5] = six
 
 def W(self):
  one = self.dice[2]
  three = self.dice[5]
  four = self.dice[0]
  six = self.dice[3]
  InsWE(one, three, four, six)

 def E(self):
  one = self.dice[3]
  three = self.dice[0]
  four = self.dice[5]
  six = self.dice[2]
  InsWE(one, three, four, six)

d = Dice(d)

for i in range(len(O)):
 if O[i] == 'S':
  d.S()
 elif O[i] == 'N':
  d.N()
 elif O[i] == 'E':
  d.E()
 elif O[i] == 'W':
  d.W()

print(d.dice[0])

Submission status: Runtime Error

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

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

dice1=dice(d)	
for com in c:
	roll(com)
print(dice1.d[0])

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self, f):
        self.f = f
        # f = face := (top, sud, est, west, nord, botm)

    
    dict = {'S' : (4, 0, 2, 3, 5, 1), \
            'E' : (3, 1, 0, 5, 4, 2), \
            'W' : (3, 1, 2, 3, 4, 5), \
            'N' : (1, 5, 2, 3, 0, 4) }
    
    def turn(self, c):
                 # c = command := 'NSEWs'
        for i in range(len(c)):
            f = [f[j] for j in dict[c[i]]]


face = list(map(int, input().strip().split()))
Dice(face).turn(input())
print(face[0])

Submission status: Runtime Error

Solution code:
class Dice:

    __top = 0
    __front = 1
    __right = 2
    __left = 3
    __back = 4
    __bottom = 5

    def __init__(self, a, b, c, d, e, f):
        self.__dice = [a,b,c,d,e,f]
        self.__dice[Dice.__top] = a
        self.__dice[Dice.__front] = b
        self.__dice[Dice.__right] = c
        self.__dice[Dice.__left] = d
        self.__dice[Dice.__back] = e
        self.__dice[Dice.__bottom] = f

    def S(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top] = dice_before[Dice.__back]
        self.__dice[Dice.__front] = dice_before[Dice.__top]
        self.__dice[Dice.__right] = dice_before[Dice.__right]
        self.__dice[Dice.__left] = dice_before[Dice.__left]
        self.__dice[Dice.__back] == dice_before[Dice.__bottom]
        self.__dice[Dice.__bottom] = dice_before[Dice.__front]

    def E(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top] = dice_before[Dice.__left]
        self.__dice[Dice.__front] = dice_before[Dice.__front]
        self.__dice[Dice.__right] = dice_before[Dice.__top]
        self.__dice[Dice.__left] = dice_before[Dice.__bottom]
        self.__dice[Dice.__back] == dice_before[Dice.__back]
        self.__dice[Dice.__bottom] = dice_before[Dice.__right]

    def W(self):
        dice_before = self.__dice[:]
        self.__dice[Dice.__top] = dice_before[Dice.__right]
        self.__dice[Dice.__front] = dice_before[Dice.__front]
        self.__dice[Dice.__right] = dice_before[Dice.__bottom]
        self.__dice[Dice.__left] = dice_before[Dice.__top]
        self.__dice[Dice.__back] == dice_before[Dice.__back]
        self.__dice[Dice.__bottom] = dice_before[Dice.__left]

    def N(self):
        dice_before = self.__dice[:]
        self.__dice[__top] = dice_before[Dice.__front]
        self.__dice[__front] = dice_before[Dice.__bottom]
        self.__dice[__right] = dice_before[Dice.__right]
        self.__dice[__left] = dice_before[Dice.__left]
        self.__dice[__back] == dice_before[Dice.__top]
        self.__dice[__bottom] = dice_before[Dice.__back]

    def top(self):
        return(self.__dice[Dice.__top])

a,b,c,d,e,f = input().split()
dice = Dice(a,b,c,d,e,f)
com = input()
for i in com:
    if i == 'S':
        dice.S()
    elif i == 'E':
        dice.E()
    elif i == 'W':
        dice.W()
    elif i == 'N':
        dice.N()

print(dice.top())

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self,l1,l2,l3,l4,l5,l6):
        self.l1 = l1
        self.l2 = l2
        self.l3 = l3
        self.l4 = l4
        self.l5 = l5
        self.l6 = l6
        self.top = 1
        self.front = 2
        self.right = 3

    def get_up_front(self):
        return eval("("+"self." + 'l' + str(self.top)+","+"self." + 'l' + str(self.front)+")")

    def get_right(self):
        return eval("self." + 'l' + str(self.right))

    def rot(self):
        self.front,self.right = self.right,7-self.front

    def move(self, order):
        if order == 'S':
            pretop = self.top
            self.top = 7 - self.front
            self.front = pretop
        elif order == 'E':
            pretop = self.top
            self.top = 7 - self.right
            self.right = pretop
        elif order == 'N':
            pretop = self.top
            self.top = self.front
            self.front = 7 - pretop
        elif order == 'W':
            pretop = self.top
            self.top = self.right
            self.right = 7 - pretop

l = list(map(int,input().split()))
q = int(input())
d = Dice(l[0],l[1],l[2],l[3],l[4],l[5])

for i in range(q):
    up,front = list(map(int,input().split()))
    while (up,front) != d.get_up_front():
        for j in range(4):
            d.move('S')
            if up == d.get_up_front()[0]:
                break
        for k in range(4):
            d.rot()
            if front == d.get_up_front()[1]:
                break
    print (d.get_right())

Submission status: Runtime Error

Solution code:
class Dice:

u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in range(len(data)):
	if roll[i] == E:
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif roll[i] == S:
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif roll[i] == W:
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif roll[i] == N:
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

Submission status: Runtime Error

Solution code:
class Dice:

u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in range(len(roll)):
	if roll[i] == E:
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif roll[i] == S:
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif roll[i] == W:
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif roll[i] == N:
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

Submission status: Runtime Error

Solution code:
class Dice:

u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in roll:
	if roll[i] == E:
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif roll[i] == S:
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif roll[i] == W:
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif roll[i] == N:
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

Submission status: Runtime Error

Solution code:
class Dice:

u,s,e,w,n,b = map(int,input().split())
roll = input()
for i in roll:
	if i == E:
		tmp = e
		e = u
		u = w
		w = b
		b = tmp
	elif i == S:
		tmp = s
		s = u
		u = n
		n = b
		b = tmp
	elif i == W:
		tmp = w
		w = u
		u = e
		e = b
		b = tmp
	elif i == N:
		tmp = n
		n = u
		u = s
		s = b
		b = tmp

print(u)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import unittest

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return __input_error()

    dice = CubicArbitraryValueDice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
    dice.put(dice.TOP, dice.SOUTH, dice.EAST, dice.WEST, dice.NORTH, dice.BOTTOM)
    
    for direction in rollings:
        dice.roll(direction)

    print(dice.faces[dice.direction[dice.TOP]])

class CubicArbitraryValueDice():
    TOP    = "top"
    BOTTOM = "bottom"
    EAST   = "E"
    WEST   = "W"
    SOUTH  = "S"
    NORTH  = "N"
    OPOSITE_DIRECTION_PAIRS = ( (EAST, WEST), (SOUTH, NORTH) )
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.faces = [n_f0, n_f1, n_f2, n_f3, n_f4, n_f5]

    #???????????¢???index?????¢??£??????
    def put(self, dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5):  #?????°????????£?????????
        self.direction = { dir_fi : i for i,dir_fi in enumerate([dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]) }

    #??¢???index????????´
    def roll(self, direction) : #dirction: (EAST, WEST, SOUTH, NORTH) ??????????????????
        for pair in self.OPOSITE_DIRECTION_PAIRS :
            if direction in pair :
                oposite = pair[0] if (pair[1] == direction) else pair[1]
        
        current = {}
        for direct in (self.TOP, self.BOTTOM, direction, oposite):
            current.update({direct : self.direction[direct]})

        #            direction to bottom,       bottom to oposite,      oposite to top,     top to direction 
        for pair in ((direction, self.BOTTOM), (self.BOTTOM, oposite), (oposite, self.TOP), (self.TOP, direction)):
            self.direction[pair[1]] = current[pair[0]]

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
        self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
    
    def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if math.isnan(eff_digit) :
                    assertfunc(value,item[1])
                else :
                    format_str = "{0:."+str(eff_digit)+"g}"
                    assertfunc(format_str.format(value),format_str.format(item[1]))
                    
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                info = []
                info.append(["arguments"     , item[0]    ])
                info.append(["compared value", item[1]    ])
                info.append(["message"       , "\n" + msg ])
                for state in info :
                    print(state[0].ljust(swidth) + ":", state[1])
                sys.exit()

        if print_success :
            print(func.__name__,": succeeded")

#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import unittest

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return __input_error()

    dice = CubicArbitraryValueDice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
    dice.put(dice.TOP, dice.SOUTH, dice.EAST, dice.WEST, dice.NORTH, dice.BOTTOM)
    
    rollings += "E"
    for direction in rollings:
        dice.roll(direction)

    print(dice.faces[dice.direction[dice.TOP]])

class CubicArbitraryValueDice():
    TOP    = "top"
    BOTTOM = "bottom"
    EAST   = "E"
    WEST   = "W"
    SOUTH  = "S"
    NORTH  = "N"
    OPOSITE_DIRECTION_PAIRS = ( (EAST, WEST), (SOUTH, NORTH) )
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.faces = [n_f0, n_f1, n_f2, n_f3, n_f4, n_f5]

    #???????????¢???index?????¢??£??????
    def put(self, dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5):  #?????°????????£?????????
        self.direction = { dir_fi : i for i,dir_fi in enumerate([dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]) }

    #??¢???index????????´
    def roll(self, direction) : #dirction: (EAST, WEST, SOUTH, NORTH) ??????????????????
        for pair in self.OPOSITE_DIRECTION_PAIRS :
            if direction in pair :
                oposite = pair[0] if (pair[1] == direction) else pair[1]
        
        current = {}
        for direct in (self.TOP, self.BOTTOM, direction, oposite):
            current.update({direct : self.direction[direct]})

        #            direction to bottom,       bottom to oposite,      oposite to top,     top to direction 
        for pair in ((direction, self.BOTTOM), (self.BOTTOM, oposite), (oposite, self.TOP), (self.TOP, direction)):
            self.direction[pair[1]] = current[pair[0]]

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
        self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
    
    def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if math.isnan(eff_digit) :
                    assertfunc(value,item[1])
                else :
                    format_str = "{0:."+str(eff_digit)+"g}"
                    assertfunc(format_str.format(value),format_str.format(item[1]))
                    
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                info = []
                info.append(["arguments"     , item[0]    ])
                info.append(["compared value", item[1]    ])
                info.append(["message"       , "\n" + msg ])
                for state in info :
                    print(state[0].ljust(swidth) + ":", state[1])
                sys.exit()

        if print_success :
            print(func.__name__,": succeeded")

#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import unittest

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return __input_error()

    dice = CubicArbitraryValueDice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
    dice.put(dice.TOP, dice.SOUTH, dice.EAST, dice.WEST, dice.NORTH, dice.BOTTOM)
    
    rollings += "E"
#    for direction in rollings:
#        dice.roll(direction)

    print(dice.faces[dice.direction[dice.TOP]])

class CubicArbitraryValueDice():
    TOP    = "top"
    BOTTOM = "bottom"
    EAST   = "E"
    WEST   = "W"
    SOUTH  = "S"
    NORTH  = "N"
    OPOSITE_DIRECTION_PAIRS = ( (EAST, WEST), (SOUTH, NORTH) )
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.faces = [n_f0, n_f1, n_f2, n_f3, n_f4, n_f5]

    #???????????¢???index?????¢??£??????
    def put(self, dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5):  #?????°????????£?????????
        self.direction = { dir_fi : i for i,dir_fi in enumerate([dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]) }

    #??¢???index????????´
    def roll(self, direction) : #dirction: (EAST, WEST, SOUTH, NORTH) ??????????????????
        for pair in self.OPOSITE_DIRECTION_PAIRS :
            if direction in pair :
                oposite = pair[0] if (pair[1] == direction) else pair[1]
        
        current = {}
        for direct in (self.TOP, self.BOTTOM, direction, oposite):
            current.update({direct : self.direction[direct]})

        #            direction to bottom,       bottom to oposite,      oposite to top,     top to direction 
        for pair in ((direction, self.BOTTOM), (self.BOTTOM, oposite), (oposite, self.TOP), (self.TOP, direction)):
            self.direction[pair[1]] = current[pair[0]]

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
        self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
    
    def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if math.isnan(eff_digit) :
                    assertfunc(value,item[1])
                else :
                    format_str = "{0:."+str(eff_digit)+"g}"
                    assertfunc(format_str.format(value),format_str.format(item[1]))
                    
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                info = []
                info.append(["arguments"     , item[0]    ])
                info.append(["compared value", item[1]    ])
                info.append(["message"       , "\n" + msg ])
                for state in info :
                    print(state[0].ljust(swidth) + ":", state[1])
                sys.exit()

        if print_success :
            print(func.__name__,": succeeded")

#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import unittest

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return __input_error()

    dice = CubicArbitraryValueDice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
#    dice.put(dice.TOP, dice.SOUTH, dice.EAST, dice.WEST, dice.NORTH, dice.BOTTOM)
    
    rollings += "E"
#    for direction in rollings:
#        dice.roll(direction)

    print(dice.faces[dice.direction[dice.TOP]])

class CubicArbitraryValueDice():
    TOP    = "top"
    BOTTOM = "bottom"
    EAST   = "E"
    WEST   = "W"
    SOUTH  = "S"
    NORTH  = "N"
    OPOSITE_DIRECTION_PAIRS = ( (EAST, WEST), (SOUTH, NORTH) )
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.faces = [n_f0, n_f1, n_f2, n_f3, n_f4, n_f5]

    #???????????¢???index?????¢??£??????
    def put(self, dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5):  #?????°????????£?????????
        self.direction = { dir_fi : i for i,dir_fi in enumerate([dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]) }

    #??¢???index????????´
    def roll(self, direction) : #dirction: (EAST, WEST, SOUTH, NORTH) ??????????????????
        for pair in self.OPOSITE_DIRECTION_PAIRS :
            if direction in pair :
                oposite = pair[0] if (pair[1] == direction) else pair[1]
        
        current = {}
        for direct in (self.TOP, self.BOTTOM, direction, oposite):
            current.update({direct : self.direction[direct]})

        #            direction to bottom,       bottom to oposite,      oposite to top,     top to direction 
        for pair in ((direction, self.BOTTOM), (self.BOTTOM, oposite), (oposite, self.TOP), (self.TOP, direction)):
            self.direction[pair[1]] = current[pair[0]]

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
        self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
    
    def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if math.isnan(eff_digit) :
                    assertfunc(value,item[1])
                else :
                    format_str = "{0:."+str(eff_digit)+"g}"
                    assertfunc(format_str.format(value),format_str.format(item[1]))
                    
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                info = []
                info.append(["arguments"     , item[0]    ])
                info.append(["compared value", item[1]    ])
                info.append(["message"       , "\n" + msg ])
                for state in info :
                    print(state[0].ljust(swidth) + ":", state[1])
                sys.exit()

        if print_success :
            print(func.__name__,": succeeded")

#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import sys
import collections
import unittest

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return __input_error()

#    dice = CubicArbitraryValueDice(faces[0], faces[1], faces[2], faces[3], faces[4], faces[5])
#    dice.put(dice.TOP, dice.SOUTH, dice.EAST, dice.WEST, dice.NORTH, dice.BOTTOM)
    
    rollings += "E"
#    for direction in rollings:
#        dice.roll(direction)

#    print(dice.faces[dice.direction[dice.TOP]])

class CubicArbitraryValueDice():
    TOP    = "top"
    BOTTOM = "bottom"
    EAST   = "E"
    WEST   = "W"
    SOUTH  = "S"
    NORTH  = "N"
    OPOSITE_DIRECTION_PAIRS = ( (EAST, WEST), (SOUTH, NORTH) )
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.faces = [n_f0, n_f1, n_f2, n_f3, n_f4, n_f5]

    #???????????¢???index?????¢??£??????
    def put(self, dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5):  #?????°????????£?????????
        self.direction = { dir_fi : i for i,dir_fi in enumerate([dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]) }

    #??¢???index????????´
    def roll(self, direction) : #dirction: (EAST, WEST, SOUTH, NORTH) ??????????????????
        for pair in self.OPOSITE_DIRECTION_PAIRS :
            if direction in pair :
                oposite = pair[0] if (pair[1] == direction) else pair[1]
        
        current = {}
        for direct in (self.TOP, self.BOTTOM, direction, oposite):
            current.update({direct : self.direction[direct]})

        #            direction to bottom,       bottom to oposite,      oposite to top,     top to direction 
        for pair in ((direction, self.BOTTOM), (self.BOTTOM, oposite), (oposite, self.TOP), (self.TOP, direction)):
            self.direction[pair[1]] = current[pair[0]]

def __input_error():
    print("input error")
    return -1

class __TestValueClass(unittest.TestCase):
    def testEqual(self, func, tuples, eff_digit = math.nan, print_success = False):
        self.testFunction(self.assertEqual,func,tuples,eff_digit,print_success)
    
    def testFunction(self,assertfunc,func,tuples,eff_digit,print_success):
        #tuples[index] = ([*arguments of func], compared value)
        for item in tuples:
            try:
                if isinstance(item[0], collections.Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if math.isnan(eff_digit) :
                    assertfunc(value,item[1])
                else :
                    format_str = "{0:."+str(eff_digit)+"g}"
                    assertfunc(format_str.format(value),format_str.format(item[1]))
                    
            except Exception as msg:
                swidth = 15
                print("="*50)
                print("-- Assertion Error in '" + func.__name__ + "' --")
                info = []
                info.append(["arguments"     , item[0]    ])
                info.append(["compared value", item[1]    ])
                info.append(["message"       , "\n" + msg ])
                for state in info :
                    print(state[0].ljust(swidth) + ":", state[1])
                sys.exit()

        if print_success :
            print(func.__name__,": succeeded")

#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    top_face_after_rolling_dice()