Robot bounded circle
A robot starts at the origin (0,0) of an infinite 2D grid facing north and executes a command string consisting of 'G' (move forward one unit), 'L' (turn left 90 degrees), and 'R' (turn right 90 degrees). The robot repeats the whole instruction sequence forever. Return True if and only if there exists some circle (of finite radius) that the robot can never escape — i.e. its trajectory is bounded. The instruction string has length 1..100.
Implement
is_robot_bounded(instructions: str) → boolExamples
in
["GGLLGG"]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 20 min
solution.py
InputExpectedGot
["GGLLGG"]truenot run yetsample