Ants On A Stick Interview Question

A new puzzle, riddle, game or interesting tidbit posted every day

ants on a stick interview question

Twenty ants are placed at random intervals along a one metre stick. Each ant faces either easterly or westerly. When the timer starts, all of the ants walk in the direction they are facing at 1cm per second. When two ants collide, they both reverse directions. How long do we need to wait to be certain that all of the ants have left the stick?

Scroll down for a clue and further down for the answer.

Clue: When two ants collide, it’s easier to think of the ants as passing through one another rather than changing directions.

Answer: 100 seconds. The trick to this question comes in realising that when two ants collide, it’s easier to think of the ants as passing through one another rather than changing directions. This means the longest possible time it will be to traverse the stick will be the time it takes for an ant to walk the 100cm which is 100 seconds.

Since every ant has two choices (pick either of two edges going through the corner on which ant is initially sitting), there are total 23 possibilities.

Out of 23 possibilities, only 2 don’t cause collision. So, the probability of collision is 6/8 and the probability of non-collision is 2/8.

Hint: Every ant has two choices (pick either of two edges going through the corner on which ant is initially sitting).

There are 3 ants sitting on three corners of a triangle. All ants randomly pick a direction and start moving along edge of the triangle. What is the probability that any two ants collide?

Answer: Collision doesn’t happen only in following two cases 1) All ants move in counterclockwise direction.

The trick is that when two ants run into each other, it is equivalent to them walking through each other. And if they just walk through each other, it is clear that the first ant starting at 0 will take 100 seconds to walk to the other end.

When two ants run into each other, they immediately turn around and walk in the other direction.

One hundred ants are dropped on a meter stick. Each ant is traveling either to the left or the right with constant speed 1 meter per minute. When two ants meet, they bounce off each other and reverse direction. When an ant reaches an end of the stick, it falls off.

The Math Behind the Fact: The answer is 1 minute! While ants bouncing off each other seems difficult to keep track of, one key idea (fun fact!) makes it quite simple: two ants bouncing off each other is equivalent to two ants that pass through each other, in the sense that the positions of ants in each case are identical. So, you might as well think of all ants acting with independent motions. Viewed in this way, all ants fall off after traversing the length of the stick, i.e., the longest that you would need to wait to ensure that all ants are off is 1 minute.

Ants on a stick may only face and move toward left or right. When two ants meet each other they bounce off and immediately move in the opposite direction maintaining the same speed entire time. When an ant reaches an end of the stick, it falls off.

Similarly we can work out this with 3 ants and putting them randomly and check out what happens in each scenario. In all cases time <= 1 minute.So 1 minute (time taken for 1 ant to cross the stick) is the answer.

If on a 1 meter long stick 25 ants are randomly kept which are moving with a constant speed of 1 meter per minute, what is the longest amount of time it could take for them to all fall off?ants-on-stick-puzzle

We can understand this more easily by breaking down the solution. Let’s say there were 2 ants and both started at the end, and meet in the middle, and then turn in opposite directions and then fall off the stick. So both have completed 1/2 + 1/2 = 1 stick and so takes 1 minute.

Ants on a Stick Puzzle | When will the stick be empty

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *