Solution #031 - piped ants


This post contains a proposed solution to Problem #031 - piped ants. Please do not read this solution before making a serious attempt at the problem.

I am excited to tell you that I just released the alpha version of my “Pydont's” book, a book that compiles all my “Pydon't” articles. You can get the book at leanpub:


This problem may look quite confusing if you try to imagine all the interactions/bumps there might be between an arbitrary number of ants inside the pipe. However, the only thing that matters to us is the time each ant takes to leave the pipe, and not the number of times the ants bump against each other!

Imagine that two ants, \(A\) and \(B\), bump against each other at a given location of the pipe. Let us suppose that \(t_A\) is the time it would take ant \(A\) to leave the pipe if it were alone in the pipe, and similarly for \(t_B\) and ant \(B\). When the two ants \(A\) and \(B\) bump against each other and turn around, ant \(A\) is now facing in the direction that \(B\) was facing, and therefore has to walk whatever \(B\) was going to walk, therefore the time that the ant \(A\) is going to take is now \(t_B\). Similarly, when the ant \(B\) turns around and faces the same distance that \(A\) was going to walk, the time it will take ant \(B\) to leave the pipe becomes \(t_A\).

When two ants bump, they swap the respective times they would take to leave the pipes if they were alone in the pipe. This shows that the ants bumping against one another does not make them spend more time in total, it just means that the ants swap the roles of the ants that were closer to the exit and farther away from the exit.

If you have any questions about my solution, found an error (woops!) or want to share your solution, please leave a comment below! Otherwise just leave an “upvote” reaction!

Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox!

If you liked this article and would like to support the mathspp project, then you may want to buy me a slice of pizza 🍕.

Previous Post Next Post

Blog Comments powered by Disqus.