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 graph was given.the x and y axes were there.the line is intersecting them.the points of intersection were y=3,x=0 and x=-2,y=0.write the equation of line.
How would you measure 4 liters using jugs of 3l and 5l? Give a few solutions to this problem?
Salary of a person is 's' per month,'x'% of salary is given as bonus, if 3 months salary is s1,s2 & s3 then what is his salary?
A man ate 100 bananas in five days, each day eating 6 more than the previous day. How many bananas did he eat on the first day?
What number comes next 10, 9, 60, 90, 70 and 66?
If a and b are positive integers and (a-b)/3.5 = 4/7, then the relation between a and b is
A family I know has several children. Each boy in this family has as many sisters as brothers but each girl has twice as many brothers as sisters. How many brothers and sisters are there?
Two trains are traveling at 18kmph and are 60 km apart. There is flying in the train. It flies at 80kmph. It flies and hits the second train and then it starts to oscillate between the two trains. At one instance when the two trains colloide it dies. At what distance travel by the fly.
A speedboat whose speed is 15 kmph in still water goes 30 kmph downstream and comes back in a total of 4hrs 30min. What is the speed of the stream in kmph?
Girish invested a certain amount at the rate of 8% p.a. for 6 year to obtain an amount of Rs. 28046.How much amount did Girish obtain as simple interest?
The average of x and y is 6.5. if z=4,what is the average of x,y,z.
Find the next series: AD DP PL LV ?
Which number does not belong to this series 1,1,2,3,4,5,8,13,21?
At 20% discount, a cycle is sold at a selling price of 2500 Rs. What is the actual price?
Find the next series number 1, 1, 2, 3, 6, 7, 10, 11, ?