Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

MF
IF (P)
GOTO B
GOTO A
-----
B: MF
GOTO B
Explanation: The first line simply gets them off the
parachutes. You
need to get the trains off their parachutes so the back
train can find
the front train's parachute, creating a special condition
that will
allow
it to break out of the code they both have to follow
initially. They
both loop through A: until the back train finds the front
train's
parachute, at which point it goes to B: and gets stuck in
that loop.
The front
train still hasn't found a parachute, so it keeps in the A loop.
Because each line of code takes a "clock cycle" to execute,
it takes
longer
to execute the A loop than the B loop, therefore the back train
(running
in the B loop) will catch up to the front train.

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Find the next series: BC CE EG GK ?

1602


Number of digits with a 2 in them between 100 and 400?

1180


Ram starts from A walking 2 km North and turns right and walks 4 km and turns right again and walks 4 km and turns right again and walks 4 km and meets Radha at Bwalking in the opposite direction to Ram . Distance between A and B

1449


A boy has Rs 3 in total. If he wins, he gains 1 Rupee and if he looses, he has to loose 1 Rupee. The boy may lose only 5 times in the game and if he earns 5 Rs, he has to quit the game. Find the number of ways of the possibilities.

1209


20% of a 6 litre solution and 60% of 4 litre solution are mixed. What percentage of the mixture of solution ?

1135


f(X)= 2X-1 + f(X-1) if X is not equal to zero and if f(X=0)=0, If f(X)=4f(X-1) then the value of X=?

1218


If 4 circles of equal radius are drawn with vertices of a square as the center, the side of the square being 7 cm, find the area of the circles outside the square?

1160


A sum of money becomes 2.5 times itself at 12.5% simple interest p.a. What should be the period of investment to get this much return?

1215


Add a word in starting of SCAPE and at the end of Grass, u will get two different word

1118


The diameter of a circle is 21 metres. It will take how many revolutions to cover a distance of 6.6 km?

1279


Complete the series..2 2 12 12 30 30 ?

1141


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

2152


In a triangle, the average of the two angles is 56 degrees where as their difference is 24 degrees. What is the measurement of the biggest angle of the triangle?

1142


Ram starts from A walking 2 km North and turns right and walks 4 km and turns right again and walks 4 km and turns right again and walks 4 km and meets Radha at Bwalking in the opposite direction to Ram . Which direction does Ram walk after the first turn?

1573


There are 9 balls of these one is defective. Find the minimum no. of chances of finding the defective one.

1292