Mad robot: Solution
A mad robot sets off towards the North East on a journey from the point (0,0) in a coordinate system. It travels in stages by moving forward and then rotating on the spot. It follows these pseudo-code instructions:
SUB JOURNEY
DISTANCE = 1000
WHILE (DISTANCE > 0.001) MOVE DISTANCE STOP ROTATE(90, DEGREES, CLOCKWISE) DISTANCE = DISTANCE / 2 END WHILE
EXPLODE
END SUB
Where does the robot explode?
Solution
First we find the number of forward turns, noting that the WHILE(DISTANCE > 0.001) condition is evaluated after each halving.
The forward motion, if it occurs, following the
th turn will be of distance
. This will occur for each
for which
![]() |
Taking logs gives
![]() |
Rearranging gives
![]() |
This first becomes invalid 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.
Let
be the total distance travelled NE. Then
![]() |
The NE motion contributes a component
travelled in the
direction and the same component
travelled in the
direction. By Pythagoras’ theorem we have
![]() |
so
![]() |
Note that the distance SE will be half of T, since each motion is half the length of the preceding NE motion. Similarly, the total distance SW will be one quarter of
; total distance NW will be one eighth of
. Each of these motions contributes the same component in the
-direction as in the
-direction. The NE direction counts positively towards both
and
directions, the SE direction counts positively in the
direction and negatively in the
direction, SW counts negatively in both
and
directions and NW counts negatively in the
and positively in the
direction. The final coordinates are therefore
![]() |
This problem comes from our sister site NRICH, which is packed with challenges, activities and articles for maths learners and teachers.

![\[ 1000\times 2^{-n} > 0.001. \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0003.png)
![\[ \log {1000}-n\log {2}>\log {0.001} \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0004.png)
![\[ n<\frac{\log {1000}-\log {0.001}}{\log {2}} = \frac{\log {1000000}}{\log {2}} \approx 19.93. \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0005.png)
![\[ T=1000\left(\frac{1}{2^0}+\frac{1}{2^4}+\frac{1}{2^8}+\frac{1}{2^{12}}+\frac{1}{2^{16}}\right). \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0007.png)
![\[ 2d^2=T^2, \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0011.png)
![\[ d=\frac{T}{\sqrt {2}}. \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0012.png)
![\[ (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{3T}{8\sqrt {2}}\right) \]](/MI/db03fb408cf4c359f5c0c2750802ae4f/images/img-0013.png)