An input string controls the movement of a robot, "F" means move 1 step forward, "L" means turn 90 degrees to the left and "R" means turn 90 degrees to the right. E.g. "FLF" moves the robot one step forward, then turns it left by 90 degrees, then moves the robot one step forward.
Write a function that returns the minimum number of commands that the robot needs to return to it's starting point after following all the input commands. You should return any characters that are not capital F, L, or R. HINT: You may wish to track the robots position using (X,Y) coordinates, assuming it starts at (0,0).
Example:
. "RF" returns 3 (robot must turn twice and move forward one step (e.g. "RRF")
. "LFRFRFR" returns 1 (robot must step forward to return )
. "FxLxLxFx" returns 0 (robot is already back at starting point )
Execution time limit is 3 secs
Input: string directions
Output: integer