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

In answer #4 , I think there is no need of these 3 lines
MF
MF
MB
Instead we can use only 1 line
MF

Both produces the same result but 1 line command is more efficient i think.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A father F has 5 sons, p,q,r,s,t. Not necessarily in this order. Two are of same age. The eldest and youngest cannot be twins. T is elder to r and younger to q and s has three older brothers. who are the twins?

859


Concentrations of three wines A, B and C are 10, 20 and 30 percent respectively. They are mixed in the ratio 2 : 3 : x resulting in a 23% concentration solution. Find x.

1395


A boy has Rs 2. He wins or loses Re 1 at a time If he wins he gets Re 1 and if he loses the game he loses Re 1. He can loose only 5 times. He is out of the game if he earns Rs 5. Find the number of ways in which this is possible?

878


A sales person multiplied a number and get the answer is 3, instead of that number divided by 3. what is th answer he actually has to get ?

760


Two trains are traveling in 60 kmph on same trace, towards each other. When the distance between them is 18 km, a fly is going to start, flying between them in 80 kmph speed. Find the traveling path distance of the fly upto when it is going to crush by the 2 trains?

694






how would you connect 8 dots with 3 lines.

1299


When the angle a, b, c, d are given find ‘x’?

729


sadrine's avg on four tests is 80 which of the following cannot be the number of tests on which she earned exactly 80 points

1674


A person with some money spends1/3 for cloths, 1/5 of the remaining for food and 1/4 of the remaining for travel. He is left with Rs 100/- . How much did he have with him in the beginning ?

855


Ajay and Vijay ave their salaries in the ratio of 2:3. If each of their salaries are increased by Rs 4000, the new ration comes to be 40:57. How much is the present salary of Vijay?

955


Find out the Simple Interest paid for a sum of $4000 at the rate of 8% per annum for 3 months.

834


a block of ice floats on water in a beaker, as the ice melts,the water level in the beaker will

674


Find the hypotaneous of a right angle isoceles triangle whose area is 50.

800


If "PROMPT" is coded as QSPLOS ,then "PLAYER" should be?

1602


in the year 1990 there are 5000 men 3000 women 2000 boys .in 1994 men are increased by 20% women are increased by ratio of boys and women

796