FastPrepRobot Path That Repeats Forever
Problems/Robot Path That Repeats Forever

Robot Path That Repeats Forever

OpenAI logoOpenAI● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from July 2024 shares photos of two questions from an OpenAI online assessment. This is the second one. A robot follows a string of step and turn commands over and over, and you decide whether some circle always contains it.

The photo asks for a batch of up to 10 command strings with a YES or NO for each. Here you get one string and return true or false. Answering each string of a batch this way gives the same results. The photo does not say which way the robot faces first. Here it faces north, which does not change any answer. The length limit of 2500 is from the photo. The examples are our own.

Our version is about 90% the same as the reported question.

On an endless flat grid, a robot begins at the point (0, 0) facing north (toward larger y). The string instructions tells it what to do, one letter at a time:

  • 'G': go one unit forward in the direction it faces.
  • 'L': a quarter turn counterclockwise, staying on the same point.
  • 'R': a quarter turn clockwise, staying on the same point.

After the last letter, the robot starts again from the first letter, and it keeps doing this forever.

Return true if some circle around the start holds the robot at every moment. Return false if no circle is big enough, because the robot wanders farther and farther away.

Function

isRobotBounded(instructions: String) → boolean

Examples

Example 1

instructions = "GGRGGRGGRGGR"return = true

Each GGR walks two steps and turns right, so one round traces a 2 by 2 square: (0, 2), (2, 2), (2, 0) and back to (0, 0), facing north again. Every round repeats the same square, whose farthest corner (2, 2) is about 2.83 units from the start, so a circle of radius 3 around the start always contains the robot.

Example 2

instructions = "GLGR"return = false

After one round the robot is at (-1, 1) and faces north again. Each further round adds the same move, so it reaches (-2, 2), (-3, 3) and so on, getting farther away forever. No circle can hold it.

Example 3

instructions = "GGGRRG"return = true

One round walks up to (0, 3), turns all the way around, and steps back to (0, 2), now facing south. The second round walks down to (0, -1), turns around again, and steps up to (0, 0), facing north. Every two rounds bring it home, and it is never more than 3 units from the start.

Constraints

  • 1 <= instructions.length <= 2500
  • instructions contains only the letters 'G', 'L' and 'R'.

More OpenAI Online Assessment questions

  • Count Routes Through Four Shop TypesOA · Seen Oct 2026
  • Digit-Sum Sequence Join PointOA · Seen Oct 2026
  • Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026
  • Password Clues and the Next CommandOA · Seen Oct 2026
  • Longest Increasing Price SubsequenceOA · Seen Oct 2026
  • Macaron Order PriceOA · Seen Oct 2026
  • Shortest Atom Action PathOA · Seen Oct 2026
  • Simplify a Quadratic ExpressionOA · Seen Oct 2026
  • Minimum-Cost Color SequenceOA · PHONE SCREEN · Seen Oct 2026
  • Largest Microorganism After ConsumptionOA · Seen Oct 2026

Similar questions at other companies

  • Find Last CharacterGoogle · OAGoogle interview questions
  • Count Prioritized Binary-Run OperationsZipRecruiter · OAZipRecruiter interview questions
  • Flip Rows and Columns, Count ZerosNutanix · OANutanix interview questions
  • Get Max DeletionsJP Morgan Chase · OAJP Morgan Chase interview questions
  • FizzBuzzIndeed · OAIndeed interview questions
  • FizzBuzzCapital One · OACapital One interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Add Decimal Strings ExactlyMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Format a Centered Pagination BarMixpanel · PHONE SCREENMixpanel interview questions

Interview reports that mention this question

  • OpenAI OA: What It Tests (2026)
All OpenAI interview questionsSee OpenAI hiring insights
Saved
class Solution {
    public boolean isRobotBounded(String instructions) {
        // Write your code here.
    }
}
Checking account…