1# Runtime: 34 ms (Top 89.04%) | Memory: 14 MB (Top 22.71%)234class Solution:5def isRobotBounded(self, instructions: str) -> bool:6pos, d = [0, 0], "N"78def move(d, pos, instructions):9for i in instructions:10if i == "G":11if d == "N":12pos[1] += 113elif d == "S":14pos[1] -= 115elif d == "W":16pos[0] -= 117else:18pos[0] += 119elif i == "L":20if d == "N":21d = "W"22elif d == "W":23d = "S"24elif d == "S":25d = "E"26else:27d = "N"28else:29if d == "N":30d = "E"31elif d == "W":32d = "N"33elif d == "S":34d = "W"35else:36d = "S"37return (d, pos)3839for i in range(4):40d, pos = move(d, pos, instructions)41return True if pos == [0, 0] else False