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

A small town's industries have a total turnover of Rs. 25,00,000. If the town council plans to raise Rs.170,000 through octroi levy, what % levy should it charge on the industries?

919


Three pipes, A, B, & C are attached to a tank. A & B can fill it in 20 & 30 minutes respectively while C can empty it in 15 minutes. If A, B & C are kept open successively for 1 minute each, how soon will the tank be filled?

724


Two lemons cost 10 cents. Then one and a half dozen cost

693


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

1357


Using the digits 1,5,2,8 four digit numbers are formed and the sum of all possible such numbers.

779






If the graphs of the equations x + y = 0 and 5y + 7x = 24 intersect at (m, n), then the value of m +n is?

950


he hour hand lies between 3 and 4. Tthe difference between hour and minute hand is 50 degree.What are the two possible timings?

951


2 Oranges,3 bananas and 4 apples cost rs.15 . 3 Oranges 2 bananas 1 apple costs rs 10. What is the cost of 3 oranges, 3 bananas and 3 apples

832


the word unimpressive was given.they asked us to do change 1st & 2nd,3rd & 4th,so on.then they asked what will be 10th letter from right?

1113


From a vessel on the first day, 1/3rd of the liquid evaporates. On the second day 3/4th of the remaining liquid evaporates. what fraction of the volume is present at the end of the II day.

965


If a refrigerator contains 12 cans such that 7 blue cans and 5 red cans. In how many ways can we remove 8 cans so that atleast 1 blue can and 1 red can remains in the refrigerator?

1756


there is a matrix N x N .Its elements consist of either value =1 or value=0. If there is a any zero in the row, then the output matrix should have all zeroes in that row. If there is a single zero in any column then that column should have all zeroes n the output matrix. write the function to perform these operations. i want a solution in c/c++ language

1881


A lorry starts from Bangalore to Mysore at 6.00 A.M,7.00am.8.00 am.....10 pm. Similarly one another starts from Mysore to Bangalore at 6.00 am,7.00 am, 8.00 am.....10.00pm. A lorry takes 9 hours to travel from Bangalore to Mysore and vice versa. A lorry which has started at 6.00 am will cross how many lorries.

912


The ratio of cost price to the market price of an article is 4: 5. What is the profit percentage if the ratio of the profit percentage on selling the article to the discount allowed on it is 5: 4?

679


What was the aggregate of marks obtained by sajal in all the six subjects?

820