@lalit:
The idea here would be for Train T,
make it cross its own parachute first. Then move both the train fwd
until
the trailing train reaches a parachute. When the trailing train
reaches the parachute
of the leading train, make it move faster than the leading train .
Naturally the leading
train would execute MF MF MB (effectively moves 1 step), and the
trailing train would
have moved 3 steps (MF MF MF) and would ultimately catch up and
collide with the
leading train.

To make things clear go thro' the code,

label:  MF MF MB
          if(parachute)
          {MF MF MF}
          GOTO label


Hope it helps,


On Jun 10, 12:06 am, LALIT SHARMA <lks.ru...@gmail.com> wrote:
>  A helicopter drops two trains, each on a parachute, onto a straight
> infinite railway line. There is an undefined distance between the two
> trains. Each faces the same direction, and upon landing, the parachute
> attached to each train falls to the ground next to the train and detaches.
> Each train has a microchip that controls its motion. The chips are
> identical. There is no way for the trains to know where they are. You need
> to write the code in the chip to make the trains bump into each other. Each
> line of code takes a single clock cycle to execute.*
> You can use the following commands (and only these);*
> MF - moves the train forward
> MB - moves the train backward
> IF (P) - conditional that's satisfied if the train is next to a parachute.
> There is no "then" to this IF statement.
> GOTO
>
> --
> Lalit Kishore Sharma,
>
> IIIT Allahabad (Amethi Capmus),
> 6th Sem.

-- 
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