Sub topic 5
Workers who join or leave midway
This chapter assumes you know the relation work = rate × time, the LCM method for choosing a total amount of work, and how to add the rates of people working together. If any of these feel shaky, revisit the earlier chapters first. Here you apply them to a team whose size changes while the job is running.
The core idea: split the timeline into phases
A worker who joins or leaves changes the combined rate. The rate is constant inside each stretch of time, so you can treat each stretch as its own small problem.
- Pick a total work (the LCM of the individual times works well).
- Convert each worker's time into a rate in units per day.
- Split the timeline into phases. Each phase has one fixed group of workers.
- For each phase, work done = combined rate × days in that phase.
- Add the work done in all phases and set the sum equal to the total. Solve for the unknown.
Always add work, never days. Days from different phases are not interchangeable, because a day with two workers does more than a day with one.
Worked example 1: one worker leaves
A can finish a job in 10 days and B in 15 days. They start together, and A leaves after 4 days. B finishes the rest. How many days does the whole job take?
Take the total work as LCM(10, 15) = 30 units. Then A does 3 units per day and B does 2 units per day.
- Phase 1: both work for 4 days at 3 + 2 = 5 units per day, which is 20 units.
- Remaining work: 30 − 20 = 10 units.
- Phase 2: B alone at 2 units per day needs 10 / 2 = 5 days.
The total time is 4 + 5 = 9 days.
Worked example 2: one worker joins late
A can finish a job in 12 days and B in 18 days. A starts alone, and B joins after 3 days. How long does the whole job take, counting from A's start?
The total work is LCM(12, 18) = 36 units. A does 3 units per day and B does 2 units per day.
- Phase 1: A alone for 3 days does 9 units.
- Remaining work: 36 − 9 = 27 units.
- Phase 2: together they do 5 units per day, so they need 27 / 5 = 5.4 days.
The total time is 3 + 5.4 = 8.4 days. The question asked for time from A's start. If it had asked how long B works, the answer would be 5.4 days.
Automating the phase method
The function below does the bookkeeping for any list of fixed-length phases plus one open-ended final phase. It uses Fraction, so answers are exact.
from fractions import Fraction
def finish_time(total, timed_phases, final_rate):
"""Total days to finish a job.
timed_phases: list of (combined_rate, days) for phases of known length.
final_rate: combined rate of the last phase, which runs until the job ends.
"""
done = Fraction(0)
elapsed = Fraction(0)
for rate, days in timed_phases:
done += Fraction(rate) * days
elapsed += days
if done >= total:
raise ValueError("work is already finished before the last phase")
return elapsed + (Fraction(total) - done) / Fraction(final_rate)
# Example 1: A (3/day) and B (2/day) work 4 days together, then B alone.
print(finish_time(30, [(5, 4)], 2)) # 9
# Example 2: A alone for 3 days, then A and B together.
print(float(finish_time(36, [(3, 3)], 5))) # 8.4
# 12 men, 20 days (240 man-days). 6 more men join after 8 days.
print(finish_time(240, [(12, 8)], 18)) # 16The ValueError guards against a common slip. If the phases you were given already complete the job, the problem statement and your rates disagree, and you should recheck them.
Working backward: "leaves x days before the end"
Some problems do not say when a worker leaves in absolute time. They say the worker leaves a number of days before completion. In that case, start from the end of the job.
A, B and C can finish a job in 12, 18 and 36 days respectively. All three start together, and A leaves 2 days before the job is completed. How long does the job take?
The total work is 36 units. The rates are A = 3, B = 2, C = 1.
- The last 2 days have only B and C, at 3 units per day, which is 6 units.
- The earlier part has all three at 6 units per day and must cover 36 − 6 = 30 units, so it takes 5 days.
The total time is 5 + 2 = 7 days.
Check: A works 5 days and does 15 units. B works 7 days and does 14 units. C works 7 days and does 7 units. The sum is 36 units.
Workers described by man-days
When workers are identical, count work in man-days. One man-day is the work one man does in one day. The total work of a job is men × days.
Twenty men can finish a job in 30 days. After 10 days, 10 men leave. How many days does the whole job take?
- Total work: 20 × 30 = 600 man-days.
- Phase 1: 20 men × 10 days = 200 man-days.
- Remaining: 400 man-days, now with 10 men, which needs 40 days.
The total is 10 + 40 = 50 days, so the job is 20 days late.
The same method works when workers join. Twelve men can finish a job in 20 days, which is 240 man-days. After 8 days, 6 more men join. The first phase does 96 man-days. The remaining 144 man-days with 18 men take 8 days. The total is 16 days, so the job is finished 4 days early. The third print in the code above checks this.
Problems where you are given a pair and one individual
Often you know the joint time and one person's time, and the other person's rate is hidden.
A and B together can finish a job in 12 days. A alone can finish it in 20 days. They start together, and A leaves after 4 days. How long does B take to finish the rest, and what is the total time?
Take the total work as LCM(12, 20) = 60 units.
- Together: 60 / 12 = 5 units per day.
- A: 60 / 20 = 3 units per day, so B = 5 − 3 = 2 units per day. (B alone would take 30 days.)
- Phase 1: 4 days × 5 = 20 units. Remaining: 40 units.
- Phase 2: B alone needs 40 / 2 = 20 days.
The answer to "how long does B take to finish the rest" is 20 days. The total job time is 24 days. Read the question for which of the two it wants.
Common errors
| Error | What goes wrong | Fix |
|---|---|---|
| Subtracting days instead of work | "A worked 4 of 10 days, so 6 days are left" ignores that B also contributed | Convert every phase to units of work, then subtract |
| Misreading "leaves after 4 days" and "leaves 4 days before the end" | The first fixes the phase boundary from the start, the second from the end | Draw a timeline and mark which end the number is measured from |
| Counting joiner days from the wrong origin | A joiner who arrives on day 3 has worked fewer days than the job has lasted | Keep total elapsed time and each person's own working time separate |
| Answering a different quantity | The question may ask for total time, remaining time, or one person's time | Underline the requested quantity before solving |
| Using the old rate after a replacement | A new worker has a different efficiency from the one who left | Recompute the combined rate for each phase |
| Treating man-days as valid for unequal workers | Man-days assume each person has the same efficiency | If efficiencies differ, convert to units per day first |
Sanity checks
- The total time must be longer than the time the full team would take alone, if someone leaves. It must be shorter than that time if someone joins.
- The total time cannot be shorter than the time the strongest possible team would need, and cannot be longer than the weakest worker's solo time.
- Add each person's individual contribution (rate × days they actually worked). The sum must equal the total work. This catches most arithmetic and phase-boundary errors.
Exercises
Exercise
A can finish a job in 20 days and B in 30 days. They start together, and A leaves 5 days before the job is completed. How many days does the job take in total?
Show answer
Take the total work as 60 units, so A does 3 per day and B does 2 per day. In the last 5 days only B works, doing 10 units. The other 50 units are done by both at 5 per day, which takes 10 days. The total is 10 + 5 = 15 days. Check: A works 10 days and does 30 units, B works 15 days and does 30 units, and the sum is 60.
Exercise
Fifteen men can build a wall in 24 days. After 6 days, 5 men leave. How many days does the whole job take, and by how many days is it delayed?
Show answer
Total work is 15 × 24 = 360 man-days. In the first 6 days, 15 × 6 = 90 man-days are done. The remaining 270 man-days with 10 men take 27 days. The total is 6 + 27 = 33 days, so the job is delayed by 33 − 24 = 9 days.
Exercise
A can finish a job in 12 days and B in 16 days. A starts alone, and B joins after 4 days. In how many days from A's start is the job finished?
Show answer
Take the total work as 48 units, so A does 4 per day and B does 3 per day. In 4 days A alone does 16 units, leaving 32. Together they do 7 per day, so they need 32/7 days. The total is 4 + 32/7 = 60/7 days, which is about 8.57 days.