Ants Escape Time on a Meter Stick
Ants on a Ruler Escape Time is an easy quant interview question on Brain Teasers.
This brain teaser describes a large number of identical ants moving along a straight line segment, all at the same speed but with randomly chosen starting positions and directions. Collisions happen whenever two ants approach each other head-on; when that occurs, they instantaneously reverse direction and continue walking. The puzzle asks for the longest possible time before every ant has completely left the segment, regardless of the complicated pattern of potential multiple collisions and direction changes.
Solving it leans on symmetry and invariance ideas from one-dimensional particle dynamics. The key observation is that when identical particles swap velocities in elastic collisions, the collection of trajectories is indistinguishable from a system where they ignore each other and pass straight through. An interviewer is looking for recognition of this equivalence, the ability to justify it clearly, and the skill to reduce a seemingly messy many-body process to a simple extremal-time calculation. It also reveals how the candidate handles idealizations, labels vs physical states, and clean reasoning about worst-case scenarios.
What it tests
When identical objects move along a line and exchange velocities upon collision, the system's evolution is equivalent to the objects passing through each other without interaction. This is because the only effect of a collision is to swap the identities (or labels) of the objects, not their positions or velocities. The underlying principle is that the set of positions and velocities at any time is preserved, regardless of which particular object occupies each position. This symmetry means that, for the purposes of calculating exit times or trajectories, you can ignore the collisions and treat the objects as non-interacting. The maximum time for any object to exit is then determined solely by its initial position and direction, not by the presence of others.
Practise this question with written feedback, or hear it in a spoken mock interview.
Get started free