A robot lands on Mars, which happens to be a cartesian grid; assuming that we hand the robot these instructions, such as LFFFRFFFRRFFF, where "L" is a "turn 90 degrees left", "R" is a "turn 90 degrees right", and "F" is "go forward one space, please write control code for the robot such that it ends up at the appropriate-and-correct destination, and include unit tests.
Here is an example output with command "FF":
[0, 2]
I could find solution to this problem on Google, but I am not very clear with the explanation. I am trying to clearly understand the logic on how to solve this and implement in Java. Any help is appreciated.
Update: This is an interview question. For now, I trying improve my knowledge. It is interesting question to me. I can remove if i am breaking any stack over rule.
Here is the research I did: Is there an equivalent of Scala's Either in Java 8?
Algorithm for finding all paths in a NxN grid
http://www.geeksforgeeks.org/check-if-a-given-sequence-of-moves-for-a-robot-is-circular-or-not/