From ecd671d7bc17b540abfac04fa7217ca6ea6f866e Mon Sep 17 00:00:00 2001 From: choiminji Date: Sat, 22 Aug 2026 23:41:13 +0900 Subject: [PATCH] Day24 --- .../1041-robot-bounded-in-circle.py" | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 "leetcode3/\354\265\234\353\257\274\354\247\200/1041-robot-bounded-in-circle.py" diff --git "a/leetcode3/\354\265\234\353\257\274\354\247\200/1041-robot-bounded-in-circle.py" "b/leetcode3/\354\265\234\353\257\274\354\247\200/1041-robot-bounded-in-circle.py" new file mode 100644 index 00000000..35ef5be9 --- /dev/null +++ "b/leetcode3/\354\265\234\353\257\274\354\247\200/1041-robot-bounded-in-circle.py" @@ -0,0 +1,28 @@ +class Solution: + def isRobotBounded(self, instructions: str) -> bool: + x, y = 0, 0 + + # 뢁, 동, 남, μ„œ + directions = [ + (0, 1), + (1, 0), + (0, -1), + (-1, 0) + ] + + direction = 0 + + for instruction in instructions: + if instruction == 'G': + dx, dy = directions[direction] + x += dx + y += dy + + elif instruction == 'R': + direction = (direction + 1) % 4 + + elif instruction == 'L': + direction = (direction - 1) % 4 + + return (x == 0 and y == 0) or direction != 0 + \ No newline at end of file