icon

Mad robot: Solution

Share this page

Mad robot: Solution

robot

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 $n$th turn will be of distance $1000\times 2^{-n}$. This will occur for each $n$ for which $$1000\times 2^{-n} > 0.001.$$ Taking logs gives $$\log{1000}-n\log{2}>\log{0.001}$$ Rearranging gives $$nThis problem comes from our sister site NRICH, which is packed with challenges, activities and articles for maths learners and teachers.

Back to puzzle