I'd rather prefer a more geometrical approach... For example: let F_1 be the figure formed by the first 4 segments of the robot's journey, F_2 be the figure formed by the segments 5th to 8th , and so on. It is easy to see that a certain (fixed) homothety of center, say, P transforms each F_i into F_{i+1} ; furthermore, P is the intersection of two perpendicular lines r and s which can be found by observing carefully F_1 and F_2 . At the end of each stage, the robot is either on r or on s , and closer and closer to P ... Completing this argument will give you an elegant solution to the problem!