Yahoo Interview Question
Software Engineer / Developersdistance = (8+2/3)*64
because the downhill become uphill when the car come back. so the average speed for the downhill or uphill is (72+56)/2 = 64.
I disagree. Let x, y, z and d be the distance of the uphill, plain, downhill, and total distance, respectively, where uphill and downhill are viewed as coming from A to B. You get 3 equations that summarize all the data :
x + y + z = d
x/72 + y/64 + z/56 = 4
x/56 + y/64 + z/72 = 4 and 2/3
The 3x3 matrix of the coefficients on the left hand side has det NOT zero, so for EVERY distance d, there are x, y, and z that solve the system.
It's also impossible that only one of these infinite solutions has all x, y and z positive...
So this can't be solved
275.69KM
The downhill,plain & regular speeds are given.As we exactly dont know whether the journey from A to B is entirely downhill and B to A as entirely uphill,we just ignore these two speeds.
Therefore,Let D be the distance and k be the average increment and decrement of speed during the to and fro journeys respectively,viz
speed*time=Distance ie
A to B: D=(64+K)*4
B to A:D=(64-k)*14/3(ie 4hrs 40min in fraction)
As D is same,therefore,
(64+k)*4=(64-k)*14/3
=(64+k)/(64-k)=14/(3*4)
solve this to get k=64/13(approx 4.92kmph)
Therefore,D=275.69KM
As A to B and B to A are considered not to be entirely downhill and uphill,the incremental speed(4.92kmph) is less than what is stated in the question 8kmph (ie 72-64 or 64-56)
x + y + z = d
x/72 + y/64 + z/56 = 4; (1)
x/56 + y/64 + z/72 = 14/3; (2)
from (1) and (2)
56x + 63y + 72z = 16128; (1')
72x + 63y + 56z = 18816; (2')
from(1') and (2')
(2') - (1') => x - z = 168;
63(x + y + z) - 7x + 9z = 16128; (1'')
63(x + y + z) - 7z + 9x = 18816; (2'')
(1'') + (2'') => 63*2(x + y + z) - 2(x - z) = 34944;
So x + y + z = 280 KM
Answer = 273
- vijay.bits February 07, 2012Let x, y, z and d be the distance of the uphill, plain, downhill, and total distance, respectively, where uphill and downhill are viewed as coming from A to B. You get 3 equations that summarize all the data :
x + y + z = d
x/72 + y/64 + z/56 = 4
x/56 + y/64 + z/72 = 4 and 2/3
Though we have only 2 equations for 3 variables, we can still solve this as we need to find (x+y+z) and not x,y,z individually.
Solving equation 2 and 3 above, we get
7x+8y+9z = 4*504 = 7 (x+y+z) + y + 2z
9x+8y+7z = 14*504/3= 9 (x+y+z) - y - 2z
Adding the above 2 equations, we get
16 (x+y+z) = 4368
Hence d = (x+y+z) = 4368/16 = 273