Microsoft Interview Question
Software Engineer / Developersthe solution is very simple
it is known that exactly in 1 hour the rope will burn
so lit the first rope from both ends and one end of second rope simultaneously.in 30 minutes first rope will burn completely and the second rope would have burnt it's 30 minutes.now 30 minutes of second rope is remainning.so burn from other end .after 15 minutes the remainning rope will burn completely.
thanks
The above solns wont work.
Its given tat ropes vary in density and dono which part will burn for 30 min
The solution will indeed work Mr. Tangent. Think of it this way. The rope takes exactly 1 hour to burn irrespective of the end you light. So if you light both ends simultaneously, then the burnings meet at the point where they each would have reached after 30 minutes. Note that this point may not be the centre of the rope
Bhagwan's answer is right. But is there one more solution possible here? I was thinking of the following: With the first rope light it at both ends and also light it at the middle of the rope. Now, the rope should burn in 15 mins. Right?
No. Remember this line: "the ropes vary in density so you don't know that half of one rope will burn for 30 minutes".
The middle of the rope doesn't really mean anything. Your solution reduces to "light at both end, and at some other arbitrary spot on the rope." That spot might as well be one inch from the left end... and that case you might as well have not lit it at all.
Sorry the just solution I typed. Actually I mis read the question, here is the solution. Just light one rope at both the ends and light another only at one end. Now when the first rope over that time light up the other rope at the remaing end so the second rope will now take 15 min more to completely
- Sudarshan Reddy December 12, 2005burn.
Sudarshan Reddy M