[READ-ONLY] Mirror of https://github.com/shuuji3/competitive-programming. 馃洬 Codes submitted to competitive programming platforms
aizu-online-jadge
aoj
atcoder
hackerrank
leetcode
2.1 kB
78 lines
1class Dice:
2 def __init__(self, top: str, front: str, right: str, left: str, back: str, bottom: str) -> None:
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 __eq__(self, other) -> bool:
11 top, front = self.top, self.front
12
13 # find top
14 found = False
15 for direction in 'SSSS':
16 other.roll(direction)
17 if other.top == top:
18 found = True
19 break
20 if not found:
21 for direction in 'EEE':
22 other.roll(direction)
23 if other.top == top:
24 break
25
26 # find front
27 for _ in range(4):
28 other.rotate_right()
29 if other.front == front:
30 break
31
32 return (
33 self.right == other.right
34 and self.left == other.left
35 and self.back == other.back
36 and self.bottom == other.bottom
37 )
38
39 def print_top(self):
40 print(self.top)
41
42 def print_right(self):
43 print(self.right)
44
45 def roll(self, direction: str) -> None:
46 if direction == 'S':
47 self.south()
48 elif direction == 'N':
49 self.north()
50 elif direction == 'E':
51 self.east()
52 elif direction == 'W':
53 self.west()
54
55 def north(self):
56 [self.top, self.back, self.bottom, self.front] = [self.front, self.top, self.back, self.bottom]
57
58 def south(self):
59 [self.top, self.back, self.bottom, self.front] = [self.back, self.bottom, self.front, self.top]
60
61 def east(self):
62 [self.top, self.right, self.bottom, self.left] = [self.left, self.top, self.right, self.bottom]
63
64 def west(self):
65 [self.top, self.right, self.bottom, self.left] = [self.right, self.bottom, self.left, self.top]
66
67 def rotate_right(self) -> None:
68 for direction in 'SWN':
69 self.roll(direction)
70
71
72dice1 = Dice(*input().split())
73dice2 = Dice(*input().split())
74
75if dice1 == dice2:
76 print('Yes')
77else:
78 print('No')