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
A person was fined for exceeding the speed limit by 10 mph. Another person was also fined for exceeding same speed limit by twice the same. If the second person was travelling at a speed of 35 mph, find the speed
The cost of one pencil, two pens and four erasers is Rs.22 while the cost of five pencils, four pens and two erasers is Rs.32.How much will three pencils, three pens and three erasers cost?
9/10 or 10/11 which is greater.
One dog tells the other that there are two dogs in front of me. The other one also shouts that he too had two behind him. How many are they?
There are 3 societies A,B,C having some tractors each. A Gives B and C as many tractors as they already have. After some days B gives A and C as many tractors as they have. After some days C gives A and B as many tractors as they have. Finally each has 24 tractors.what is the original No.of tractors each had in the beginning?
In the combinations of 2,3,6,7 how many possible combinations divisible by 4?
there are 76 persons. 53 can read hindu,46 can read times,39 can read deccan and 15 can read all.if 22 can read hindu and deccan and 23 can read deccan and times then what is the number of persons who read only times and hindu………
f(X)=4f(X-1) THEN VALUE OF X=
hai am Deepak here i have my exam on 3rd jan 2010 for the post of officers job in karnataka bank so kindly plz send me model papers . thank u
Two circles , one circle is inscribed and another circle is N outscribed over a square. What is the ratio of area of inner to outer circle.
Find the next number in the series. 1, 0.5, 0.25, 0.125
In a 10 digit number, if the 1st digit number is the number of ones,2nd digit number is the number of twos, and ... so on. 10th digit is the number of zeroes,then find the number
A train 100 meter long takes 3 second to cross a man walking at the rate of 6km/hr in a direction opposite to that of the train. Find the speed of the train.
If m/n = 5/4 , then 2m+n= ?
Four persons can cross a bridge in 3, 7, 13, 17 minutes. Only two can cross at a time. Find the minimum time taken by the four to cross the bridge.