Sub topic 11
Repeated removal and replacement from a container
This chapter assumes you are comfortable with ratios, percentages, and the weighted-average view of a mixture from the earlier chapters. It also assumes you know the alligation rule and can work with fractions and powers such as (9/10)². The aim is to derive the repeated-replacement formula, so you can apply it with understanding and spot the cases where it does not apply.
The setup
A container holds V litres of a pure liquid. You draw off x litres and replace them with water, so the container is full again. You repeat this several times. The question usually asks one of these:
- How much pure liquid is left after n rounds?
- What is the ratio of pure liquid to water at the end?
- What was the original volume, or how much was drawn each time?
The key is to track the pure liquid only. Water is added each round, but the pure liquid only ever decreases.
Deriving the formula for one round
Before the first draw, the container is entirely pure, so the fraction of pure liquid is 1. After you stir (or just assume the mixture is uniform), every litre drawn off has the same composition as the whole container.
- The container holds V litres, and you remove x litres.
- You remove the fraction x/V of the contents.
- The fraction that stays behind is 1 − x/V = (V − x)/V.
Pure liquid is removed in proportion to its share of the contents. So after one round:
pure left = V × (1 − x/V)
Refilling with water changes the total back to V but adds no pure liquid. The pure amount, V(1 − x/V), is now the starting amount for round two.
The n-round formula
Round two removes the same fraction x/V of whatever pure liquid is present. Each round multiplies the pure amount by (1 − x/V), so after n rounds:
pure left = V × (1 − x/V)^n
Dividing by V gives the same result as a fraction of the container:
pure fraction after n rounds = (1 − x/V)^n
The water is whatever remains of the container: V − pure left.
Worked example 1
A container holds 40 litres of pure milk. 4 litres are drawn off and replaced with water. This happens twice. How much milk is left, and what is the ratio of milk to water?
- Fraction left each round: 1 − 4/40 = 9/10.
- Milk left: 40 × (9/10)² = 40 × 81/100 = 32.4 litres.
- Water: 40 − 32.4 = 7.6 litres.
- Ratio milk : water = 32.4 : 7.6 = 324 : 76 = 81 : 19.
The ratio 81 : 19 comes straight from the fraction: (9/10)² = 81/100, so milk is 81 parts out of 100.
from fractions import Fraction
volume = 40 # litres of pure liquid at the start
drawn = 4 # litres removed and replaced with water each time
times = 2
pure_left = volume * (1 - Fraction(drawn, volume)) ** times
print(pure_left) # 162/5, which is 32.4 litres
print(float(pure_left)) # 32.4
print(volume - pure_left) # 38/5, which is 7.6 litres of waterUsing Fraction keeps the arithmetic exact, so you can compare results without rounding errors.
Why this is a weighted average
One round is a weighted-average (alligation) step. After drawing off x litres you hold (V − x) litres of concentration c. You add x litres of concentration 0 (water). The new concentration is:
c_new = [(V − x) × c + x × 0] / V = c × (1 − x/V)
This is the same factor as before. The concentration shrinks by a constant multiple each round, which is why the result is a power.
When the replacement is not water
The same reasoning handles a replacement liquid of concentration r (for example, a weaker solution). Measure concentration as a distance from r. Each round shrinks that distance by the factor (1 − x/V):
cn − r = (c0 − r) × (1 − x/V)^n
When r = 0 (water) this reduces to cn = c0 (1 − x/V)^n.
Worked example 2
A 100-litre container holds an 80% acid solution. 20 litres are drawn off and replaced with a 30% solution. This happens twice. What is the final concentration?
- Factor: 1 − 20/100 = 0.8.
- Distance from the replacement: c_0 − r = 0.80 − 0.30 = 0.50.
- After two rounds: 0.50 × 0.8² = 0.50 × 0.64 = 0.32.
- c_2 = 0.30 + 0.32 = 0.62, so the solution is 62% acid.
Step-by-step check: after round one, acid = 80 × 0.8 + 20 × 0.3 = 64 + 6 = 70 litres (70%). After round two, acid = 80 × 0.7 + 6 = 62 litres (62%). Both routes agree.
def replace_concentration(c0, r, drawn, volume, times):
"""Concentration after repeated draw-and-refill with a liquid of concentration r."""
factor = 1 - drawn / volume
return r + (c0 - r) * factor ** times
print(round(replace_concentration(0.80, 0.30, 20, 100, 2), 4)) # 0.62
print(round(replace_concentration(1.00, 0.00, 4, 40, 2), 4)) # 0.81Unequal draws
If the amounts differ from round to round, the formula becomes a product of different factors:
pure left = V × (1 − x₁/V) × (1 − x₂/V) × …
For example, 100 litres of pure liquid: draw off 20 litres and replace with water, then draw off 10 litres and replace with water. Pure liquid left = 100 × 0.8 × 0.9 = 72 litres.
The container volume V stays the same in every factor, because the container is refilled each time. If the container is not refilled to V, then the denominator in the next factor changes. Check this whenever a question says "partly" refilled.
Working backwards
A question may give the final amount and ask for the amount drawn or the original volume. Set up the equation and take roots.
Worked example 3
A container holds 64 litres of milk. Some milk is drawn off and replaced with water, and the same amount is drawn and replaced again. The container now has 49 litres of milk. How much is drawn each time?
- (1 − x/64)² = 49/64.
- Take the square root: 1 − x/64 = 7/8.
- x/64 = 1/8, so x = 8 litres.
Taking the square root works here because both numbers are perfect squares. CAT questions are usually designed this way. If the ratio is not a neat power, you probably have a different structure in mind and should recheck the question.
Two liquids in the container
Suppose the container starts as a mixture of A and B in the ratio 3 : 2, with 50 litres in total. You draw off 10 litres and replace with B. Draw-off removes both liquids in their current ratio, so apply the factor to each liquid separately.
- A initially: 30 litres. After one round: 30 × (1 − 10/50) = 24 litres.
- B initially: 20 litres. B removed: 20 × 10/50 = 4 litres, and 10 litres of B are added. B is now 20 − 4 + 10 = 26 litres.
- Ratio A : B = 24 : 26 = 12 : 13.
Only the liquid that is not being added shrinks by the factor. The added liquid is found by subtraction from the total, since the total stays at 50 litres.
Finding the number of rounds
Some questions ask when the pure fraction first falls below a threshold. There is rarely a closed form that is easier than testing powers, so try successive values of n.
from fractions import Fraction
def rounds_until_below(volume, drawn, threshold):
"""Smallest n such that the pure fraction (1 - drawn/volume)**n < threshold."""
factor = 1 - Fraction(drawn, volume)
fraction = Fraction(1)
n = 0
while fraction >= threshold:
fraction *= factor
n += 1
return n
# 40 litres, 4 litres per round: when does pure liquid drop below half?
print(rounds_until_below(40, 4, Fraction(1, 2))) # 7Check by hand: (0.9)⁶ ≈ 0.531 is still above one half, and (0.9)⁷ ≈ 0.478 is below it, so 7 rounds are needed. Note that the pure fraction never reaches zero. Each round multiplies it by a positive number less than 1.
Common traps
| Trap | What goes wrong | Fix |
|---|---|---|
| Using x as the fraction | Writing (1 − x)^n with x = 4 litres | Use the ratio x/V, the drawn amount over the full container |
| Dividing by the pure amount | Using (1 − x/pure) in round two | The denominator is always the whole container V |
| Counting the water twice | Subtracting water from V again | Water = V − pure left, computed once at the end |
| Forgetting a partial refill | Using V in every factor when the volume shrinks | Recompute the total volume for each round |
| Mixing the two liquids' formulas | Applying the shrink factor to the added liquid | Shrink the liquid that is only removed, then find the other by subtraction |
| Misreading "n times" | Counting the first draw as round zero | Each draw-and-refill is one round; n rounds means n factors |
Choosing a method
- Pure liquid replaced by water, same amount each time: use V(1 − x/V)^n.
- Replacement with a liquid of concentration r: use the distance form cn − r = (c0 − r)(1 − x/V)^n.
- Different amounts each round: multiply the separate factors.
- A single round only: treat it as a weighted average or alligation step. The power form adds nothing.
- Final amount known, draw amount unknown: set (1 − x/V)^n equal to the known fraction and take the root.
Exercise
A container holds 80 litres of pure milk. 8 litres are drawn off and replaced with water. This is done three times in total. How much milk is left, and what is the ratio of milk to water at the end?
Show answer
The factor per round is 1 − 8/80 = 9/10. Milk left = 80 × (9/10)³ = 80 × 0.729 = 58.32 litres. Water = 80 − 58.32 = 21.68 litres. The fraction of milk is 729/1000, so the ratio milk : water = 729 : 271.
Exercise
A container holds 50 litres of pure milk. A fixed amount x is drawn off and replaced with water, and this is done twice. The container then holds 32 litres of milk. Find x.
Show answer
(1 − x/50)² = 32/50 = 16/25. Taking the square root gives 1 − x/50 = 4/5, so x/50 = 1/5 and x = 10 litres.
Exercise
A 60-litre container holds a mixture of A and B in the ratio 2 : 1. 12 litres are drawn off and replaced with B. What is the new ratio of A to B?
Show answer
The factor is 1 − 12/60 = 4/5. A initially = 40 litres, so A now = 40 × 4/5 = 32 litres. Total is still 60, so B = 28 litres. Ratio A : B = 32 : 28 = 8 : 7.