On Feb 16, 12:53 pm, bittu <shashank7andr...@gmail.com> wrote:
>  Two robots are placed at different points on a straight line of
> infinite length. When they are first placed down, they each spray out
> some oil to mark their starting points.
>
> You must program each robot to ensure that the robots will eventually
> crash into each other. A program can consist of the following four
> instructions:
>
>     * Go left one space
>     * Go right one space
>     * Skip the next instruction if there is oil in my current spot
>     * Go to a label
>
> [Note that a "label" is a name that refers to a line of your code. For
> example, you could label the third line of your program "surveying".
> Then, the instruction "goto surveying" would jump to line 3 and start
> executing from there on the next cycle.]
>
> A robot will carry out one instruction per second. Both robots need
> not have the same program. Note that you won't know ahead of time
> which robot is on the left and which is on the right.
>
> Thanks & Regards
> Shashank Mani

RIGHT   // Move off the starting spot
Search: RIGHT  // Move at speed of 1 space every third turn until you
find the other robot's starting spot
SKIP NEXT INSTRUCTION IF OIL
GOTO Search
Fast: RIGHT // Move at speed of 1 space every other turn
GOTO Fast

Both robots will move to the right, but the one on the left will
eventually find the oil left by the other robot and begin moving
faster, eventually catching up with the other robot.

Don

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to