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

Answer Posted / jubalau

had this too. i was allowed to number the lines

1 mf
2 if p go to 4
3 go to 1
4 mf
5 go to 4

you could also add more mf lines between lines 4 and 5 for better results i guess...

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What would be the simple interest obtained on an amount of Rs. 5580 at the rate of 6.5 % p.a. after 5 years?

1364


In a fraction, if 1 is added to both the numerator at the denominator, the fraction becomes 1/2. If numerator is subtracted from the denominator, the fraction becomes 3/4. Find the fraction.

685


If the vertex (5,7) is placed in the memory. First vertex (1,1) ?s address is 1245 and then address of (5,7) is ----------

896


If LOAD = MPBE and DRIVE = ESJWF Then LADDLER = ?

921


Jack and Jill went up and down a hill. They started from the bottom and Jack met Jill again 20 miles from the top while returning. Jack completed the race 1 min a head of Jill. If the hill is 440 miles high and their speed while down journey is 1.5 times the up journey. How long it took for the Jack to complete the race ?

1070






The minute hand of a clock overtakes the hour hand at intervals of 64 minutes of correct time. How much a day does the clock gain or lose?

807


A person runs 6 ft in 1/4 sec. how much it will run in 10 sec. ans 240

3514


A building with hight D ft shadow upto G A neighbour building with what height shadow C ft is?

735


Rakesh buys 1 gallon of milk for Rs.12 and mixes it with 20% water. He then sells it for Rs.15, What is the percentage of gain that Rakesh would get.

721


The rectangle box with square base is open at the top. The maximum volume of the box made from 1200 m2 tin,in m3 is?

914


three students appear in a test but no one write there name on answer sheet .and they submitted their sheet to teacher . when teacher distributed their answer sheet . what is probability that no one get their own answer sheet.

705


Next number in the series 1, 1/2, 1/4, 1/8 ?

685


How Can A Cake(circular) Be Cut Into 8 Pieces By Making Just 3 Cuts?

663


A ship went on a voyage after 180 miles a plane statrted with 10 times speed that of the ship. Find the distance when they meet from starting point.

723


The average score of a cricketer for 13 matches is 42 runs. If his average score for the first 5 matches is 54, then what was his average score (in runs) for last 8 matches?

830