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:
# coding: utf-8
# Here your code !
from sys         import exit
from collections import Iterable
from unittest    import TestCase

import numpy as np

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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))

class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = np.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = np.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = np.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = np.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = np.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = np.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( np.dot(self.OPERATOR[operator], np.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]

'''
def __input_error():
    print("input error")
    return -1
'''
class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

        if print_success :
            print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    pass
#    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
from sys         import exit
from collections import Iterable
from unittest    import TestCase

import numpy as np

def top_face_after_rolling_dice():
    try:
        faces    = [int(num) for num in input().rstrip().split()]
        rollings = input().rstrip()
    except:
        return -1#__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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))

class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = np.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = np.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = np.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = np.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = np.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = np.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( np.dot(self.OPERATOR[operator], np.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]

'''
def __input_error():
    print("input error")
    return -1
'''
class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

        if print_success :
            print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    pass
#    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
from sys         import exit
from collections import Iterable
from unittest    import TestCase

import numpy

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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))

class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = numpy.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = numpy.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = numpy.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = numpy.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = numpy.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = numpy.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( numpy.dot(self.OPERATOR[operator], numpy.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]


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

class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

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

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
from sys         import exit
from collections import Iterable
from unittest    import TestCase

import numpy

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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))
'''
class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = numpy.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = numpy.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = numpy.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = numpy.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = numpy.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = numpy.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( numpy.dot(self.OPERATOR[operator], numpy.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]

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

'''
class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

        if print_success :
            print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    pass
#    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
from sys         import exit
from collections import Iterable
from unittest    import TestCase
import numpy

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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))
'''
class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = numpy.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = numpy.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = numpy.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = numpy.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = numpy.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = numpy.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( numpy.dot(self.OPERATOR[operator], numpy.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]

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

'''
class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

        if print_success :
            print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    pass
#    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
import numpy
from sys         import exit
from collections import Iterable
from unittest    import TestCase

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 operator in rollings:
        dice.roll(operator)

    print(dice.get_value(dice.TOP))
'''
class CubicArbitraryValueDice():
    (TOP, BOTTOM, EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) = ("top", "bottom", "E", "W", "S", "N", "R", "L")
    (stVALUE, stDIRECTION) = ("value", "direction")

    (plus_x, minus_x, plus_y, minus_y, plus_z, minus_z) = ( (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), (0,0,1), (0,0,-1) )

    ROLL_x2y = numpy.array([ [ 0,-1, 0], [ 1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2x = numpy.array([ [ 0, 1, 0], [-1, 0, 0], [ 0, 0, 1] ])
    ROLL_y2z = numpy.array([ [ 1, 0, 0], [ 0, 0,-1], [ 0, 1, 0] ])
    ROLL_z2y = numpy.array([ [ 1, 0, 0], [ 0, 0, 1], [ 0,-1, 0] ])
    ROLL_z2x = numpy.array([ [ 0, 0, 1], [ 0, 1, 0], [-1, 0, 0] ])
    ROLL_x2z = numpy.array([ [ 0, 0,-1], [ 0, 1, 0], [ 1, 0, 0] ])
    
    DIRECTION = { EAST : plus_x,   WEST : minus_x,  NORTH : plus_y,   SOUTH : minus_y,  TOP   : plus_z,   BOTTOM : minus_z }
    OPERATOR  = { EAST : ROLL_z2x, WEST : ROLL_x2z, NORTH : ROLL_z2y, SOUTH : ROLL_y2z, RIGHT : ROLL_y2x, LEFT   : ROLL_x2y }
    
    #??¢???index??§???????????????????????????
    def __init__(self, n_f0, n_f1, n_f2, n_f3, n_f4, n_f5):
        self.info = [ {self.stVALUE: n_fi} for n_fi in [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):  #?????°????????£?????????
        for (info, dir_fi) in zip(self.info, [dir_f0, dir_f1, dir_f2, dir_f3, dir_f4, dir_f5]):
            info.update({ self.stDIRECTION : self.DIRECTION[dir_fi]})

    #??¢???index????????´
    def roll(self, operator) : #dirction: (EAST, WEST, SOUTH, NORTH, RIGHT, LEFT) ??????????????????
        for info in self.info:
            info[self.stDIRECTION] = tuple( numpy.dot(self.OPERATOR[operator], numpy.array(info[self.stDIRECTION])))

    def get_value(self, direction):
        for info in self.info:
            if info[self.stDIRECTION] == self.DIRECTION[direction] :
                return info[self.stVALUE]
    
    def get_direction(self, value):
        for info in self.info:
            if info[self.stVALUE] == value :
                return info[self.stDIRECTION]

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

'''
class __TestValueClass(TestCase):
    def testEqual(self, func, tuples, eff_digit = None, 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], Iterable):
                    value = func(*item[0])
                else:
                    value = func(item[0])
                
                if eff_digit is None :
                    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 info_state in info :
                    print(info_state[0].ljust(swidth) + ":", info_state[1])
                exit()

        if print_success :
            print(func.__name__,": succeeded")
'''
#test
if __name__ == "__main__" :
#    test = __TestValueClass()
    pass
#    top_face_after_rolling_dice()

Submission status: Runtime Error

Solution code:
import numpy

Submission status: Runtime Error

Solution code:
#dice
D=[int(i) for i in input().split()]
Os=input()
for i in range(len(Os)):
    if Os[i]=="N":
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif Os[i]=="S":
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
elif Os[i]=="E":
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
elif Os[i]=="W":
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t        
print(D[0])

Submission status: Runtime Error

Solution code:
class Dice:
    current = 1
    num = {}
    map = {
        1:{'N':2, 'S':5, 'E':4, 'W':3},
        2:{'N':6, 'S':1, 'E':4, 'W':3},
        3:{'N':6, 'S':1, 'E':2, 'W':5},
        4:{'N':6, 'S':1, 'E':5, 'W':2},
        5:{'N':6, 'S':1, 'E':4, 'W':3},
        6:{'N':5, 'S':2, 'E':4, 'W':3},
        }
    def __init__(self, num):
        for i, v in enumerate(num):
             self.num[i+1] = v
    def move(self, direct):
        self.current = self.map[self.current][direct]
        return self.map[self.current][direct]
    def getNum(self):
        return self.num[self.current]
def move(direction):
    num = map(int, raw_input().split())
    a = Dice(num)
    for d in direction:
        a.move(d)
    return a.getNum()
if __name__ == '__main__':
    assert move('SE') == 8, '8'
    assert move('EESWN') == 32, '32'

Submission status: Runtime Error

Solution code:
def move_func(dice_list, dir):
	new_dice = []
	if dir=="N":
		new_dice.append(dice_list[1])
		new_dice.append(dice_list[5])
		new_dice.append(dice_list[2])
		new_dice.append(dice_list[3])
		new_dice.append(dice_list[0])
		new_dice.append(dice_list[4])
	elif dir=="E":
		new_dice.append(dice_list[3])
		new_dice.append(dice_list[1])
		new_dice.append(dice_list[0])
		new_dice.append(dice_list[5])
		new_dice.append(dice_list[4])
		new_dice.append(dice_list[2])
	elif dir=="S":
		new_dice.append(dice_list[4])
		new_dice.append(dice_list[0])
		new_dice.append(dice_list[2])
		new_dice.append(dice_list[3])
		new_dice.append(dice_list[5])
		new_dice.append(dice_list[1])
	elif dir=="W":
		new_dice.append(dice_list[2])
		new_dice.append(dice_list[1])
		new_dice.append(dice_list[5])
		new_dice.append(dice_list[3])
		new_dice.append(dice_list[4])
		new_dice.append(dice_list[0])
	return new_dice

try:
	while True:
		dice_list = input().split(" ")
		move_cmd = input()
		for cmd in  move_cmd:
			dice_list = move_func(dice_list, cmd)
			
		print(dice_list[0])
except EOFError:
	pass

Submission status: Runtime Error

Solution code:
class Dice:
    def __init__(self):
        self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front
    def set(self,l):
        self.dice=l
    def roll(self, s):
        import copy
        mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))
        l=copy.deepcopy(self.dice)
        if s == 'N': c = 0
        if s == 'S': c = 1
        if s == 'E': c = 2
        if s == 'W': c = 3
        for i in range(6):
            print('i=%d, c=%d, mat[i][c]=%d, %d->%d'%(i,c,mat[i][c],self.dice[i],l[mat[i][c]]))
            self.dice[i]=l[mat[i][c]]
    def get(self):
        return self.dice

d=Dice()
d.set(list(map(int,input().split)))
s=input()
for i in range(len(s)):
    d.roll(s[i])
print(d.get()[0])