The problem itself is trivial. I know of a similar question that got asked in an Amazon intern interview. Here are some relevant follow-ups (though not so hard either) (not that all of them actually got asked in the interview)
- Can you tell whether the robot will return to (0,0) after any move of the sequence of moves rather than just the end?
- Can you tell whether the robot will ever repeat to any point after any move of the sequence?
- Can you tell whether this repeating point is a corner of the circle or not?
- What if we precludes lines like
UUDDfrom the definition of "circle"?
Please inform me if any of these followups seems unreasonable. I can only recall these vaguely, based on somebody else's recount in the first place, so mistakes might occur. I don't have code for them, but I think most of these followups are doable and still within the ballpark of "easy" problems.