I recently applied to a job and took a programming test. I didn't hear back, so I'm assuming I didn't get the position. I was able to answer all of the questions except one. I'm trying to find out what the answer is because its been bugging me, but I'm not having any luck. The question is a math calculation.
A man is standing in the middle of a long dry riverbed when he sees a wall of water heading towards him. If the water is moving at 8 times the speed at which the man can run, then he’ll have the best chance of escape by running:
A) Straight toward a river bank
B) Toward a bank, but at a slight angle away from the water
C) Away from the water, but at a slight angle toward the bank
Give a short explanation of your reasoning. Establish your answer mathematically.
Does anybody know what exactly needs to be done to find the optimal path? Is there an exact equation to use?
The answer is A.
according to Pythagorean theorem if run at slight angle than distance will surly be slight greater than any of side,
let me explain.
a = straight distance from dry riverbed to bank .
b = slight angle distance from dry riverbed to bank
c = a-b = distance between straight and angled run..
here b will become our hypotenuse
b = sqrt(a^2 + (a-b)^2) will surly greater than a..
The way you reuse the same letters there for different things is cute.
Let the point where the man stands be A. Let the point on the bank that is the shortest distance from the man be point B. Let the point one foot downstream from point B be point C.
50
A-------------------------B
| 1
50.01 C
You'll have to use your imagination for AC.
If the line AB is 50 feet, and BC is 1 foot, AC (the hypotenuse) is 50.01. If the rate of speed the man is moving at is 1 foot per second, he's spent .01 seconds to gain 1 foot. The question now becomes whether the wall of water can cover the distance of 1 foot in .01 seconds. If it cannot, the man has improved his chances of making the bank; if it can, he's screwed. Since the water is moving at 8 times the speed of the man, we know that the water in this case would be moving at 8 feet per second. 8 feet per second for .01 seconds is .08 feet. Since .08 feet is considerably less than 1 foot, the man improves his chances.
Let w be the distance of the water, D be the perpendicular distance to the bank, and t be the angle you run at (+ve = away from water, 0=straight to bank). With a bit of trig you can derive that the you will survive if:
w/D >= (8-sin(t))/cos(t)
To get this, pick an arbitrary point on the bank, and say that the time you get there, must be <= than the time the water gets there.
Obvoisuly in the worst case you are far from the bank and the water is really close, so to increase chances of surviving you need to find the angle that minimizes the expression. Plotting some graphs, it looks to be about 7.18 degrees away from the water.
My turn.
Suppose that you just barely made it to the bank. Now, let's go back in time to see which path did you take.
When you get to the middle, the distance from you to the wall will be the `survive' distance. The path that minimizes this distance is the one we want. \[ d = wv - sqrt(v^2 - h^2) \] where `d' is the distance, `v' is our speed and `w' is the water's relationship to our speed (8 in the problem)
So, derive the equation \[ w - \frac{ v } { sqrt(v^2 - h^2) } \]
Here we could eliminate A. Taking the limit when v->h, we'll see that the sign is negative (there is improvement).
So let's solve the minimum: \frac{v}{ sqrt(v^2 - h^2) } = \frac{ 1 }{ \sin \phi }
So the `best' angle to run is \[ \sin \phi = \frac{1}{w} \]
OK. This question interests me more than the presidential debate.
I think everyone above is incorrect. There is no one answer; the choice depends on the distance the water is from the man compared to the distance the man is from the shore.
Answer a) is correct if the man can run to the shore before the water reaches him. Consider that the distance from the shore to the man is d1 and the distance form the water to the man is d2. The time it takes for the man to run to the shore is d2/v, where v is the speed at which the man can run. The time it takes for the water to reach the man is d1/8v.
If d2/v is less than d1/8v, then the man can reach the shore before the water reaches him. That translates to if the water is more than 8 times away from him as he is from the shore (8*d2 < d1), then the man should run directly, or perpendicularly, to the shore; choice a).
If the water will reach the man is less than d2/v minutes, then the man needs more time to get to the shore. He gets this extra time by an angle to the shore that is greater than 90 degrees.
Let the angle between the perpendicular and the man's path to shore by given by alpha. The man's speed perpendicular to the shore is now vcos(alpha) and the time to reach the shore is now d2/vcos(alpha). The extra distance the water must travel to reach the man (his distance downshore from the perpendicular) is vsin(alpha) * d2/vcos(alpha). So the total distance the water must travel to reach the man is d1 + d2tan(alpha).
The time for the water to reach the man is now [d1 + d2tan(alpha)]/8v. If the time for the man to reach the shore is less than the time for the water to reach the man, d2/vcos(alpha) < [d1 + d2tan(alpha)]/8v, then the man should select choice b). This translates in distance to 8d2 < d1cos(alpha) + d2sin(alpha), then choose b).
If 8d2 > d1cos(alpha) + d2sin(alpha) then the man cannot reach the shore before the water reaches him in any case, and should choose c) in order to delay the inevitable as much as possible.
If someone wants to solve for alpha and develop an expression for the decision as a function of alpha, they can go ahead. I am interested in that solution but not enough to solve it myself.
There is no one answer; the choice depends on the distance the water is from the man compared to the distance the man is from the shore.
The choice is completely unaffected by the relative distances. In order to have the best chance for survival in any circumstance you angle away from the water.
The only logic you're offering up is that the choice doesn't matter in certain situations, and that simply isn't true. If you factor in the possibility of tripping or getting mired down along the path, choice B wins out as there is more time to remedy any such occurrence. It is the path with the best chance of escape.
@cire...as you say The question now becomes whether the wall of water can cover the distance of 1 foot in .01 seconds.
by this you mean that 1 feet distance is BC..hope i am right..
why would water goes from B to C and more importantly how it could possible..? water wall will cover B and C simultaneously.
and AC is higher than AB...
The choice is completely unaffected by the relative distances. In order to have the best chance for survival in any circumstance you angle away from the water.
I do not follow your argument here because your own post above (at 3:10 am) demonstrates the opposite of your criticism of my solution and supports my argument.
In your example, the man is 50 feet from the shore and can run at 1 foot per second. Running directly to the shore, from point A to point B, will take him 50 seconds.
The water travels at 8 feet per second. If the water is 8,000 feet from the man, it will take 1,000 seconds for it to reach him. The man is safely out of harm's way for 950 seconds by the time the water arrives. There is no reason for the man to angle his run to the shore, covering a longer distance is more time, unless he simply likes the scenery.
Whereas if the water is 240 feet, it will reach the man is 30 seconds. The man MUST angle his run to the shore to give him more time to reach it, even though doing so forces him to run a longer distance.
I agree with kev82's approach, though he didn't follow it through very deeply. Still, his statement that
... pick an arbitrary point on the bank, and say that the time you get there, must be <= than the time the water gets there.
But the question is about maximizing the chance of survival, not about maximizing it while optimizing distance traveled.
We're not given any distances, so the solution chosen has to be correct (i.e. none of the other solutions can improve your chances of survival) for all possible scenarios. There are scenarios where A performs worse than B, but none where B performs worse than A, therefore B is the better solution. Likewise for B and C. Therefore, B is the best solution.
> the choice depends on the distance the water is from the man compared to the distance the man is from the shore.
Let's call `d' the distance from the man to the wall of water, and `h' the distance to the shore (the shortest distance, perpendicular).
Using \sin \phi = \frac{1}{w} the ratio `d/h' would be minimum, that means that the water could be closer.
If you can't survive with that angle, you can't survive at all. (for w>1)