1
class Robot:
2

3
def __init__(self, width: int, height: int):
4
self.perimeter = 2*width + 2*(height - 2)
5
self.pos = 0
6
self.atStart = True
7

8
self.bottomRight = width - 1
9
self.topRight = self.bottomRight + (height - 1)
10
self.topLeft = self.topRight + (width - 1)
11

12
def step(self, num: int) -> None:
13
self.atStart = False
14
self.pos = (self.pos + num) % self.perimeter
15

16
def getPos(self) -> List[int]:
17
if 0 <= self.pos <= self.bottomRight:
18
return [self.pos, 0]
19

20
if self.bottomRight < self.pos <= self.topRight:
21
return [self.bottomRight, self.pos - self.bottomRight]
22

23
if self.topRight < self.pos <= self.topLeft:
24
return [self.bottomRight - (self.pos - self.topRight), self.topRight - self.bottomRight]
25

26
return [0, self.topRight - self.bottomRight - (self.pos - self.topLeft)]
27

28
def getDir(self) -> str:
29
if self.atStart or 0 < self.pos <= self.bottomRight:
30
return 'East'
31

32
if self.bottomRight < self.pos <= self.topRight:
33
return 'North'
34

35
if self.topRight < self.pos <= self.topLeft:
36
return 'West'
37

38
return 'Sout

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0