A pipe normally fills a tank in 8 hours, but because of a leak it takes 10 hours. How long would the leak take to empty a full tank?
40 hours. Leak rate = normal rate - actual rate = 1/8 - 1/10 = 1/40 of the tank per hour. With 40 units: the pipe adds 5, the net is 4, so the leak removes 1 unit per hour.
Explain it simply
The leak is the difference between how fast the tank should fill and how fast it actually fills. Find both rates, subtract, and the leftover is the leak. Then the leak alone empties a full tank in 1 divided by its rate.
Example
Question: Normally 8 hours to fill; with a leak, 10 hours. Leak alone empties in?
- Tank = LCM(8, 10) = 40 units.
- Pipe alone = 5 units/h. Pipe with leak = 4 units/h.
- Leak = 5 - 4 = 1 unit/h.
- Leak empties 40 units in 40 hours.
Shortcut: leak time = (a x b) / (b - a) = (8 x 10) / (10 - 8) = 40.
const a = 8, b = 10;
console.log((a * b) / (b - a)); // Output: 40Check: 1/8 - 1/40 = 5/40 - 1/40 = 4/40 = 1/10, so the tank fills in 10 hours with the leak.
What to say in the interview
"The leak's rate is the normal filling rate minus the actual rate: one eighth minus one tenth, which is one fortieth. So it empties a full tank in 40 hours."
Common mistakes
- Answering 2 hours (10 - 8).
- Mixing up which rate is bigger: the normal rate must be the larger one.