[READ-ONLY] Mirror of https://github.com/shuuji3/competitive-programming. 馃洬 Codes submitted to competitive programming platforms
aizu-online-jadge aoj atcoder hackerrank leetcode
0

Configure Feed

Select the types of activity you want to include in your feed.

1class Dice: 2 def __init__(self, top, front, right, left, back, bottom): 3 self.top = top 4 self.front = front 5 self.right = right 6 self.left = left 7 self.back = back 8 self.bottom = bottom 9 10 def print_top(self): 11 print(self.top) 12 13 def roll(self, direction): 14 if direction == 'S': 15 self.south() 16 elif direction == 'N': 17 self.north() 18 elif direction == 'E': 19 self.east() 20 elif direction == 'W': 21 self.west() 22 23 def north(self): 24 [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom] 25 26 def south(self): 27 [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top] 28 29 def east(self): 30 [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom] 31 32 def west(self): 33 [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top] 34 35 36labels = input().split() 37directions = input() 38 39dice = Dice(*labels) 40for direction in directions: 41 dice.roll(direction) 42dice.print_top()