Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions leetcode3/최원준/1041. Robot Bounded In Circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Solution:
def isRobotBounded(self, instructions: str) -> bool:
dirs = [
[0, 1],
[1, 0],
[0, -1],
[-1, 0]
]

instructions *= 4

cords = [0, 0]
dir = 0

for ins in instructions:
if ins == "G":
cords[0] += dirs[dir][0]
cords[1] += dirs[dir][1]

elif ins == "R":
dir = (dir + 1) % 4

elif ins == "L":
dir = (dir - 1) % 4

return cords == [0, 0]