Our thanks go to azerbajdzan for correcting an error in the original solution to this challenge
The first part of this journey consists of a sequence of forward motions followed by 90 degree turns. Although we could just halve repeatedly to find the number of turns, we might consider the possibility that the numbers in the problems might change, so look for a general proceduce for finding the number of motions.
In doing this, we need to be careful about the number of forward turns and note that the WHILE(DISTANCE > 0.001) condition is evaluated after each halving.
The forward motion, if it occurs, following the $n$th turn will be of distance $1000\times 2^{-n}$.This will occur for each $n$ for which
This first becomes invalid AFTER after 20 turns. Thus, the path of the robot is determined by $20$ motions. The directions that the robot travels in these 20 motions are alternately NE, SE, SW, NW, .... Since there are 20 motions in total there are 5 motions in each of these directions.
Note that the distance SE will be half of this, since each motion is half the length of the preceding NE motion. Similarly, total distance SW will be one quarter of $T$; total distance NW will be one eight of $T$. Each of these motions contributes a component in the $x$-direction and component in the $y$-direction.
The final coordinates will therefore be
$$
(x, y) = \left(\frac{T}{\sqrt{2}}\left(1+\frac{1}{2}-\frac{1}{4}-\frac{1}{8}\right),\frac{T}{\sqrt{2}}\left(1-\frac{1}{2}-\frac{1}{4}+\frac{1}{8}\right)\right)=\left(\frac{9T}{8\sqrt{2}}, \frac{3 T}{8\sqrt{2}}\right)
$$