y). It is loaded with a program program made of commands:
- G: drive 1 unit forward;
- L: turn 90° left (counterclockwise);
- R: turn 90° right (clockwise).
The rover runs the program and, as soon as it reaches the end, starts it over again, forever.
Return True if the rover's whole path fits inside some circle on the plane (it never wanders arbitrarily far), and False otherwise.program='GRG' → True
After one run the rover is at (1, 1) facing east. Each further run turns the path another 90°, so after four runs it is back at the start, walking around a square.
program='GLRG' → False
The turns cancel out: the rover faces north again but has moved 2 cells, and every run takes it further away.
program='GGRR' → True
The rover walks 2 cells and turns around; the second run brings it back to the start.
program consists of the characters G, L, Rprogram='GRG'
True
Run checks the first 3 tests in your browser. Submit checks all 143 tests on the server, hidden ones included.