ā back to unit
Easy
# breaking it down easy
Robot on a Line
The little robot starts at 0 and follows orders: L is one step left, R one step right. š¤
You get the moves as a string of L and R. Print end <final position> and far <the farthest distance from 0 it ever reached> on one line.
Example:
Input: moves = "RRLRR"
Output: end 3 far 3
The position walks 1, 2, 1, 2, 3 ā ending at 3, and the farthest it ever strayed from 0 was also 3, reached right at the end.
š” need a hint?
brk-robot-line.pyš given lines are locked ā write your code in between
loading...