wood burning stoves*
The moose likes Programming Diversions and the fly likes Two  train and a bird puzzle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Two  train and a bird puzzle" Watch "Two  train and a bird puzzle" New topic
Author

Two train and a bird puzzle

rehans oberoi
Ranch Hand

Joined: Dec 06, 2005
Posts: 174
One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they crash, how far will the bird have traveled?
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1006
    
    3
Originally posted by rehans oberoi:
One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they crash, how far will the bird have traveled?


Just so the problem is self-contained, let's say that the traintrack is 2800 miles long.
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
bird flight distance = 0 if the bird was sitting on the tracks when the L/A train pulled out of the station.

(I know silly, boundary case with tenuous justification, but its almost Friday)
[ March 09, 2006: Message edited by: Reid M. Pinchback ]

Reid - SCJP2 (April 2002)
Vinayak patil
Ranch Hand

Joined: Aug 30, 2005
Posts: 67
Distance = 2800 miles.
Time = 2800/35 = 80 hrs.
So bird travels 25*80 = 2000 miles.


"I can resist everything except temptation"
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
You forgot about the flying back and forth part; that is just the first leg of the trip.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Reid: No, it's all included actually. 80 hours is the total time bevfore collision. During that time, the bird is flying either west-east or east-west at 35 mph. In terms of total ground covered (scalar distance, not vector displacement) the direction doesn't matter, and the infinite number of direction reversals at the end doesn't need to be calculated directly. 80 hours at 35 mph gives 2000 miles.

And note that your earlier "boundary case" is clearly contradicted by the problem statement.
[ March 10, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Ashok Mash
Ranch Hand

Joined: Oct 13, 2000
Posts: 1936
Originally posted by Vinayak patil:
Distance = 2800 miles.
Time = 2800/35 = 80 hrs.
So bird travels 25*80 = 2000 miles.


Good stuff, very clear thinking!


[ flickr ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

There's an old (probably untrue) story that when John von Neumann was asked this question, he thought for a few seconds and then gave the correct answer. The asker said "Very good! Most people don't see the easy way and sum the infinite series instead." To which von Neumann said "I did sum the infinite series."
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Originally posted by Jim Yingst:
And note that your earlier "boundary case" is clearly contradicted by the problem statement.


Yes, but my interpretation is more fun! Just because the bird can fly fast doesn't mean it can hop up from the track fast enough to not get squashed. Kinda like the "what is in my pocket?" riddle.
[ March 10, 2006: Message edited by: Reid M. Pinchback ]
 
wood burning stoves
 
subject: Two train and a bird puzzle
 
Similar Threads
Can a H1B dependent work ?
Audio in Java
Best Swing Development Environment
New York City: World's Greatest City
Census: Los Angeles Area Is Fastest Growing in Nation