Sub topic 11
Leaks and delayed filling
This chapter assumes you are comfortable with fractions and reciprocals, with LCM, and with the rule that rates add when agents work together. It also assumes you know that an inlet pipe has a positive rate and an outlet pipe has a negative rate. You already know how to find a net filling time. Here you will learn to recognize problems where a leak is hidden in the wording, and to work backward from a delay to the leak's rate.
What a leak is in rate terms
A leak is an outlet pipe that nobody opened on purpose. It drains the tank whenever the tank holds water. In rate terms it is just a negative rate.
- If a leak empties a full tank in L hours, its rate is -1/L of the tank per hour.
- If an inlet fills the tank in F hours, its rate is +1/F of the tank per hour.
- The net rate is the sum: 1/F - 1/L.
- The time to fill from empty is the reciprocal of the net rate, provided the net rate is positive.
The leak's "empties in L hours" figure usually refers to a full tank. This is an idealization that CAT problems almost always adopt. They treat the leak as draining at a constant rate, however much water is in the tank.
from fractions import Fraction
inlet = Fraction(1, 6) # fills the tank in 6 hours
leak = Fraction(-1, 10) # empties the tank in 10 hours (negative rate)
net = inlet + leak
print(1 / net) # 15The inlet alone needs 6 hours. With the leak, the same tank needs 15 hours. The leak adds 9 hours.
The delayed-filling pattern
Many problems never mention the leak's rate. They give you two filling times, one without the leak and one with it, and ask how long the leak alone would take to empty the tank.
The setup is always the same:
- Write the inlet rate from the normal filling time.
- Write the net rate from the delayed filling time.
- Subtract: leak rate = inlet rate - net rate (as a positive quantity).
- Take the reciprocal to get the emptying time.
Worked example: a pipe fills a tank in 8 hours. Because of a leak it takes 12 hours. How long does the leak take to empty a full tank?
Use the LCM method. Take the total as LCM(8, 12) = 24 units.
- Inlet rate: 24 / 8 = 3 units per hour.
- Net rate: 24 / 12 = 2 units per hour.
- Leak rate: 3 - 2 = 1 unit per hour.
- Emptying time: 24 / 1 = 24 hours.
from math import lcm
total = lcm(8, 12) # 24 units
inlet = total // 8 # 3 units per hour
net = total // 12 # 2 units per hour
leak = inlet - net # 1 unit per hour
print(total / leak) # 24.0The leak alone empties a full tank in 24 hours.
Phrasing variants
The same pattern hides behind different wording. Learn to translate each one.
| Wording | Translation |
|---|---|
| "takes 2 hours longer than usual" | Delayed time = normal time + 2 |
| "takes 20% longer" | Delayed time = 1.2 × normal time |
| "the tank is filled in 9 hours instead of 6" | Inlet time 6, net time 9 |
| "a leak that loses 1/3 of the water supplied" | Leak rate = 1/3 of the inlet rate |
| "a leak empties the full tank in 12 hours" | Leak rate = -1/12 per hour |
The "loses a fraction of the water" wording ties the leak to the inlet rate. If the leak loses 1/4 of what the inlet supplies, the net rate is 3/4 of the inlet rate, so the filling time becomes 4/3 of the normal time.
A shortcut for the "hours longer" form
When a problem says the delay is d hours, you can often skip the rates. Let the normal time be F, the delayed time be F + d, and the emptying time be L. Then:
1/F - 1/L = 1/(F + d)
Solving for L gives:
L = F(F + d) / d
For the example above, F = 8 and d = 4, so L = 8 × 12 / 4 = 24 hours. This matches the LCM result.
def leak_time(normal, delayed):
"""Hours for the leak alone to empty a full tank."""
delay = delayed - normal
return normal * delayed / delay
print(leak_time(8, 12)) # 24.0
print(leak_time(6, 15)) # 10.0The second line reproduces the earlier example: a 6-hour inlet and a 10-hour leak give a 15-hour filling time.
Use the formula only when the data fits the pattern exactly. The LCM method is safer when the problem adds extra conditions.
Fractions of the tank
Some problems give the fraction of the tank filled or lost, not the full-tank time.
Worked example: a tank is filled by a pipe in 5 hours. A leak at the bottom can empty the full tank in 8 hours. If the tank is empty and both are active, how long to fill it halfway?
Use the LCM method with 40 units for a full tank.
- Inlet: 8 units per hour.
- Leak: -5 units per hour.
- Net: 3 units per hour.
- Half the tank is 20 units, so the time is 20 / 3 = 6 2/3 hours.
Filling a fraction of the tank takes that fraction of the full net time. Full time here is 40 / 3 hours, and half of it is 20 / 3 hours.
Leak that starts partway
Sometimes the leak appears after some time, or the tank starts partly full.
Worked example: an inlet fills a tank in 6 hours. After 2 hours, a leak develops that would empty a full tank in 10 hours. How long in total to fill the tank?
Use 30 units as the full tank.
- Inlet rate: 5 units per hour.
- Leak rate: -3 units per hour.
- After 2 hours: 10 units filled, 20 units remaining.
- Net rate afterward: 2 units per hour.
- Time for the rest: 20 / 2 = 10 hours.
- Total: 2 + 10 = 12 hours.
from math import lcm
total = lcm(6, 10) # 30 units
inlet = total // 6 # 5 per hour
leak = total // 10 # 3 per hour
filled = inlet * 2 # 10 units in the first 2 hours
remaining = total - filled
print(2 + remaining / (inlet - leak)) # 12.0The key step is to split the problem into phases, each with its own net rate. Add up the phase durations at the end.
When the tank never fills
If the leak is faster than the inlet, the net rate is zero or negative, and the tank never fills from empty. A problem will not ask for a filling time in that case. A different question may still be valid: if the tank starts full, how long until it empties?
- Inlet fills in 12 hours, so its rate is +1/12.
- Leak empties in 8 hours, so its rate is -1/8.
- Net rate: 1/12 - 1/8 = -1/24.
- A full tank empties in 24 hours.
Always check the sign of the net rate before taking a reciprocal. A negative result for a "time to fill" means the problem is set up wrongly, or you swapped the inlet and the leak.
from fractions import Fraction
net = Fraction(1, 12) - Fraction(1, 8)
if net > 0:
print("fills in", 1 / net)
elif net < 0:
print("empties in", -1 / net)
else:
print("level stays constant")Why delays grow faster than the leak
A small leak can cause a large delay when the inlet is only slightly faster than the leak. The net rate is a difference, so it shrinks quickly as the two rates approach each other.
- Inlet 6 hours, leak 100 hours: net time 100 × 6 / 94 ≈ 6.38 hours.
- Inlet 6 hours, leak 10 hours: net time 15 hours.
- Inlet 6 hours, leak 7 hours: net time 42 hours.
from fractions import Fraction
def fill_time(inlet_hours, leak_hours):
net = Fraction(1, inlet_hours) - Fraction(1, leak_hours)
return 1 / net
for leak_hours in (100, 10, 7):
print(leak_hours, float(fill_time(6, leak_hours)))This is a useful sanity check. If a problem says a tiny leak doubles the filling time, the numbers deserve a second look.
Common errors
- Adding the leak as positive. The leak must be subtracted. If your filling time becomes shorter than the inlet alone, you added it.
- Subtracting times instead of rates. The leak time is 24 hours, not 12 - 8 = 4 hours. Always convert to rates first.
- Mixing the delay with the leak time. The delay is how much longer filling takes. The leak time is how long the leak alone needs to empty a full tank. They are different quantities.
- Forgetting the phases. If the leak starts late or stops early, a single net rate does not apply to the whole period.
- Using partial-tank figures for the leak. The leak time refers to a full tank unless the problem says otherwise.
Checks before you move on
- The net rate must be smaller than the inlet rate whenever a leak is present.
- The delayed filling time must be longer than the normal time.
- The leak's emptying time must be longer than the delayed filling time. If the leak could empty the tank faster than the tank fills, something is wrong.
- Plug your answer back in: inlet rate minus leak rate should give the net rate you started with.
Exercise
A pipe fills a tank in 9 hours. Because of a leak, it takes 12 hours to fill the tank. How long would the leak alone take to empty a full tank?
Show answer
Take the LCM of 9 and 12, which is 36 units. The inlet rate is 36 / 9 = 4 units per hour. The net rate is 36 / 12 = 3 units per hour. The leak rate is 4 - 3 = 1 unit per hour. The leak empties the full tank in 36 / 1 = 36 hours.
Exercise
A pipe fills a tank in 4 hours. A leak loses one fifth of the water the pipe supplies. How long does the tank take to fill?
Show answer
The inlet rate is 1/4 of the tank per hour. The leak removes 1/5 of that, so the net rate is 4/5 of 1/4, which is 1/5 of the tank per hour. The tank fills in 5 hours.
Exercise
An inlet fills a tank in 10 hours. After 4 hours a leak starts that would empty a full tank in 15 hours. How many hours in total does the tank take to fill?
Show answer
Take 30 units as the full tank. The inlet rate is 3 units per hour and the leak rate is 2 units per hour. In the first 4 hours the inlet fills 12 units, leaving 18. The net rate afterward is 3 - 2 = 1 unit per hour, so the rest takes 18 hours. The total is 4 + 18 = 22 hours.