Pipes A and B fill a tank in 12 and 15 minutes. Pipe C empties it in 20 minutes. If all three are opened together on an empty tank, how long will it take to fill?
10 minutes. With 60 units of tank: A adds 5, B adds 4, C removes 3 per minute. Net 6 units per minute, so 60/6 = 10 minutes.
Explain it simply
Assign plus signs to pipes that fill and minus signs to pipes that empty, add everything into one net rate, and divide. Choosing the tank size as the LCM of all the times makes every rate a whole number, so you never handle messy fractions.
Example
Question: A fills in 12 min, B in 15 min, C empties in 20 min. All open.
- Tank = LCM(12, 15, 20) = 60 units.
- A = +5, B = +4, C = -3 units per minute.
- Net = 6 units per minute.
- Time = 60 / 6 = 10 minutes.
Variation: with only B and C open on an empty tank, the net is 4 - 3 = +1 unit a minute, so it still fills, but takes 60 minutes. Always check the sign of the net rate before dividing.
const tank = 60;
console.log(tank / (tank / 12 + tank / 15 - tank / 20)); // Output: 10What to say in the interview
"I take the tank as 60 units. A and B add 5 and 4 a minute, C removes 3, net 6, so it fills in 10 minutes."
Common mistakes
- Adding C's rate instead of subtracting it.
- Taking the tank as 12 x 15 x 20 units, which works but slows you down.