Hacker News new | ask | show | jobs
by TrackerFF 1675 days ago
I like the infamous Von Neumann "Fly and the trains" math/physics problem - mainly because it's very easy to solve the easy way, or you can go about it the harder way. And apparently Von Neumann did it on the spot, the harder way, almost instantaneous.

It goes like this (stolen from a website - there are many variations on this):

Problem: Two trains are on the same line, 60 miles apart, heading towards each other, each traveling at 30 mph. A fly that can travel at 60 mph leaves one engine flying towards the other. Upon reaching the other engine, it instantaneously turns around, and heads back to the other engine. This is repeated until the two trains crash and the fly is annihilated at the same time.

Question: How far does the fly travel before it is "splatted"?

3 comments

I think the problem here is posed in a way where there is a simple trick (because the fly flies exactly 2 times faster than one of the trains).

From the reference of a train, the other train is coming at 60 mph, which is equal to the speed of the fly.

So the problem would be equivalent to having the fly be stuck on the windshield of a 60 mph train until it collides with a train at 0 mph.

It takes 1 hour to move 60 miles at 60 mph. So the fly flies 60 miles.

If I recall in the original problem the fly flies at a different speed compared to the train (relative to the driver of the train), just to make it conceptually a little harder.

I'll try it. I hope I do not make a stupid mistake.

When the first train has travelled one third of the distance separating it from the other train, the fly will have travelled two thirds of this distance, and the other train one third of the distance, in the opposite way, which means it is exactly the moment at which the fly hits the second train and turns back.

Let d be the initial distance between both trains. Now we are solving almost the same problem (the speeds do not change, and the way the fly travels is irrelevant, the problem is symmetric), the only parameter changing is the distance, now being 2/3 * d.

We can reason the same way ad infinitum and we identify the distance D travelled by the fly is the following:

D = 2/3 d + 2/3 (2/3 d) + ... D = 2/3 d + (2/3)^2 d + (2/3)^3 d + ... D = d * {sum for n from 1 to infinity}{(2/3) ^ n} D = 3d

The fly travels 3 times the distance between the trains before dying.

Indeed, doing the infinite sum is the "hard" way.

The easier way is to notice that the trains will collide in 1h and the fly will be constantly be flying at a speed of 60mph for the entire time. So the fly will travel 60 miles in the alloted time.

It means I actually made a mistake! I understand your solution. :)
Yeah, the distance changes by a factor of 1/3 each time (which actually makes for an easier infinite sum), not 2/3.
Reminds me of the ants-on-a-stick problem.

100 ants are spaced evenly on a 1m stick. They travel at 1m/minute. When an ant bumps into another ant, they both turn around and go the other way. When an ant reaches the end of the stick it falls off.

How long before all the ants fall off?

That's not solvable as stated. I think you may have accidentally misstated the question.

> 100 ants are spaced evenly on a 1m stick

Are the ends at the end of the line of evenly spaced ants on the very ends of the stick?

> They travel at 1m/minute.

Is each ant initially traveling? What is the initial travel direction of each traveling ant?

This matters because if the ants are all traveling in initially traveling then (assuming maximal even initial spacing) it would take 1 minute for the last ant to fall off, but if each ant were initially traveling towards the nearest end it would take about 1/2 minute.

Googling, I found almost the same problem except that the question asked was what is the minimum time that guarantees all ants will have fallen off no matter what their initial directions are.

Does it matter if they are evenly spaced? I think max time needed is the same if they are randomly spaced.
You are correct. Even spacing does not matter.

There are many initial configurations that achieve the maximum time before the last ant falls off the stick, and that includes configurations where they are evenly spaced and configurations where all but one ant is randomly spaced (achieving maximum time requires that at least one ant be in a particular initial state--I'm being vague to avoid spoilers).

(This is all assuming mathematical ants...point sized and can change direction instantly)