A pipe fills a tank in 10 hours, but a leak at the bottom can empty the full tank in 15 hours. With both working, how long does the tank take to fill?
30 hours. Net rate = 1/10 - 1/15 = (3 - 2)/30 = 1/30 of the tank per hour. With 30 units: the pipe adds 3, the leak removes 2, net 1 unit per hour.
Explain it simply
Pipes and cisterns is time and work with a twist: some pipes do negative work. A leak is like a friend who keeps eating the laddoos you are packing. Add the filling rates, subtract the emptying rates, and divide the tank by the net rate.
Example
Question: Fill pipe: 10 h. Leak: empties in 15 h. Both open.
- Tank = LCM(10, 15) = 30 units.
- Pipe = +3 units/h. Leak = -2 units/h. Net = +1 unit/h.
- Time = 30 / 1 = 30 hours.
Notice how a leak that is "slower" than the pipe still triples the filling time. Rates that nearly cancel make the time very long.
console.log(30 / (30 / 10 - 30 / 15)); // Output: 30What to say in the interview
"I take 30 units as the tank. The pipe adds 3 an hour, the leak removes 2, so the net is 1 unit an hour and it takes 30 hours."
Common mistakes
- Adding the rates as though the leak helped.
- Subtracting times: 15 - 10 = 5 hours means nothing here.