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
The numbers A, B and C make a sum of 98. If the ratio A:B is 2:3 and that B:C is 5:8, the third number would be
A is driving on a highway when the police fines him for over speeding and exceeding the limit by 10 km/hr.same time B is fined for over speeding by twice the amount by which A exceeded the limit.If he was driving at km/hr what is the speed limit for the road?
falling height is proportional to square of the time. one object falls 64cm in 2sec than in 6sec from how much height the object will fall.
A farmer has a farm square of 100 sq.m a cow is tied at one and with a rope of 10m length.assume pi-3.what is the area of land the cow can graze.
X < 0, Y <> 0 then what is the possibility that the result is always positive?
r= 5 n = 3 . If first pole has 2 flags ,third pole has 1 flag how many ways the remaining can be arranged?
. Which of the following is not a VSAM dataset. a. KSDS b. RRDS c. LSDS d. ESDS
During a given week an author spends 1/4 of his time preparing first drafts, 3/8 of his time editing the drafts and the rest of the time in preparing final drafts. If he works 48 hours during the week, how many hours did he spend in preparing final drafts?
The lowest temperature in the night in a city A is 1/3 more than 1/2 the highest during the day. Sum of the lowest temperature and the highest temperature is 100 degrees. Then what is the low temp?
(998-1)(998-2)(998-3).....(998-n)= ? when n>1000
A is twice efficient than B. A and B can both work together to complete a work in 7 days. Then find in how many days A alone can complete the work?
If shalu buys 6 more apples, his carton will weigh 14.5 kilograms.if the weight of one apple is 250 grams.how many apples did he initially had in his carton?
15 tennis players take part in a tournament. Every player plays twice with each of his opponents. How many games are to be played?
A father is 30 years older than his son however he will be only thrice as old as the son after 5 years what is father's present age ?
There are two natural numbers. A cube difference of the squares is a square difference of their cubes.These are the smallest possible numbers. what is the sum of these numbers?