Senior 6 min · March 06, 2026

Time Speed Distance — Average Speed Trap Delayed ETAs

Planned arrival times showed early — system averaged speeds as (s1+s2)/2 causing 30%+ ETA errors.

N
Naren Founder & Principal Engineer

20+ years shipping production code across the stack, with years spent interviewing engineers. Written from production experience, not tutorials.

Follow
Production
production tested
May 24, 2026
last updated
1,554
articles · all by Naren
 ● Production Incident 🔎 Debug Guide
Quick Answer
  • Core relationship: Distance = Speed × Time, with three rearrangements
  • Unit conversion is the #1 trap: km/h to m/s multiply by 5/18, minutes to hours divide by 60
  • Relative speed: add speeds when moving toward, subtract when same direction
  • Average speed is total distance / total time, never the arithmetic mean
  • Performance insight: A 1-second error in speed conversion mis-calculates ETA by minutes at highway speeds
  • Production insight: Ride-hailing ETA engine used arithmetic mean — average was off by 30% on mixed-speed routes
✦ Definition~90s read
What is Time Speed Distance Problems?

Time-speed-distance (TSD) problems are the arithmetic backbone of motion calculations, used everywhere from logistics route planning to competitive exam puzzles. The core relationship — distance equals speed multiplied by time (D = S × T) — is deceptively simple.

Imagine you're on a road trip.

The trap is that real-world motion is rarely uniform: speeds change, units mismatch (km/h vs m/s), and objects move relative to each other. Most engineers and data scientists have been burned by naively averaging speeds, which fails because time spent at each speed matters, not just the speed values themselves.

This article focuses on the specific failure mode where averaging speeds leads to delayed ETAs — a common bug in delivery routing, fleet management, and travel time estimation systems.

The fundamental issue is that average speed is not the arithmetic mean of speeds. If you drive 60 km/h for 1 hour and 120 km/h for 1 hour, your average speed is 90 km/h — but if you drive 60 km/h for 1 km and 120 km/h for 1 km, your average speed is 80 km/h.

The harmonic mean governs when distances are equal; the arithmetic mean only works when times are equal. This distinction is critical for any system computing ETAs from variable-speed segments. The article covers unit conversion pitfalls (e.g., converting km/h to m/s by multiplying by 5/18), relative speed calculations for two moving objects (add speeds for opposite directions, subtract for same direction), and specialized cases like boats in streams (upstream speed = boat speed − stream speed) and circular track problems where relative speed determines lap meeting times.

In practice, these concepts appear in GPS routing algorithms, warehouse robot path planning, and even network packet latency calculations. The alternative to manual TSD computation is using time-series speed data with weighted averages, but the core formulas remain essential for sanity-checking automated systems.

When not to use these formulas: when acceleration is non-negligible (use kinematic equations instead), when dealing with probabilistic arrival times (use stochastic models), or when the path is not linear (use geodesic distances). For most deterministic motion problems with constant or piecewise-constant speeds, TSD is the correct tool — but only if you avoid the average speed trap.

Plain-English First

Imagine you're on a road trip. You know your car does 60 miles every hour, and you need to travel 180 miles — how long will it take? That simple question IS a time-speed-distance problem. The three values are always connected: if you know any two, you can always find the third. Think of it like a triangle where covering one corner always reveals the other two.

Time, speed, and distance problems show up everywhere — from Google Maps calculating your arrival time to airline pilots computing fuel burn rates. They're not just textbook puzzles. Any system that involves movement, throughput, or rates is secretly a TSD problem. That's why every major tech company, consulting firm, and bank includes them in their aptitude screening rounds — they test whether you can model a real situation mathematically under time pressure.

The core challenge isn't the formula itself (it's just three words: Distance equals Speed times Time). The real difficulty is knowing which form of the formula to use, how to handle unit mismatches, and how to set up problems that involve multiple moving objects or direction changes without losing track of what's relative to what.

By the end of this article you'll be able to instantly classify any TSD problem into one of five patterns, apply the right formula variant without second-guessing yourself, avoid the three unit-conversion traps that cost candidates marks, and confidently walk an interviewer through your reasoning on the trickiest relative motion scenarios.

Why Average Speed Is a Trap in Time-Speed-Distance Problems

Time-speed-distance problems compute travel time given distance and speed, or derive speed from time and distance. The core mechanic is simple: time = distance / speed. But the trap is averaging speeds over segments. If you drive 60 km at 30 km/h and 60 km at 60 km/h, the average speed is not 45 km/h — it's 40 km/h, because time spent at each speed differs. The harmonic mean governs total time, not the arithmetic mean.

In practice, this means any system that estimates ETA by averaging speeds across legs will be wrong. The correct approach: compute total distance divided by total time. For two equal-distance legs at speeds v1 and v2, average speed = 2 v1 v2 / (v1 + v2). For unequal distances, you must sum distances and sum times separately.

Use this whenever your system predicts arrival times from segment-level speed data — ride-hailing, delivery logistics, fleet management. Getting average speed wrong directly inflates or deflates ETAs, eroding user trust and causing SLA breaches.

Harmonic Mean Trap
Average speed over multiple legs is the harmonic mean of the leg speeds weighted by distance, not the arithmetic mean. Never average speeds directly.
Production Insight
A food delivery platform computed ETA by averaging GPS speed samples over the route. During a lunch rush, drivers slowed in a 5 km construction zone to 10 km/h while the rest of the 15 km route was 40 km/h. The system reported 30 min ETA; actual was 45 min. Rule: always compute total distance / total time — never average speeds.
Key Takeaway
Average speed over multiple legs is harmonic mean, not arithmetic mean.
Total time = sum of (distance / speed) for each segment — never average speeds.
ETA errors from speed averaging compound non-linearly; always use total distance / total time.
Time Speed Distance: Average Speed Trap Delayed ETAs THECODEFORGE.IO Time Speed Distance: Average Speed Trap Delayed ETAs Key concepts and pitfalls in solving TSD problems Core Formula: D = S × T Three forms: D=S×T, S=D/T, T=D/S Unit Conversion Trap Convert km/h to m/s: multiply by 5/18 Relative Speed Same direction: subtract; opposite: add Average Speed Pitfall Do NOT average speeds; use total distance/total time Catch-Up Problem One starts later; equate distances when they meet Boats, Streams & Trains Effective speed = speed ± stream/wind speed ⚠ Average speed is NOT the arithmetic mean of speeds Always compute total distance divided by total time THECODEFORGE.IO
thecodeforge.io
Time Speed Distance: Average Speed Trap Delayed ETAs
Time Speed Distance Problems

The Core Formula: D = S × T and Its Three Forms

The relationship is simple: Distance = Speed × Time. From that you can derive Speed = Distance / Time and Time = Distance / Speed. The trick is picking the right form without second-guessing. Always ask: which variable am I solving for?

Example: A car travels 240 km at 60 km/h. Time = 240 / 60 = 4 hours. If instead you know time and distance, apply the appropriate rearrangement.

In interviews, problems rarely hand you the exact formula you need. They'll give you two quantities and leave the third hidden. Your job is to identify which form to use.

Production Insight
A pilot used knots for speed but statute miles for distance — the unit mismatch caused an unscheduled landing.
Always validate units with dimensional analysis before any calculation.
Rule: Dimensional consistency is not optional — ever.
Key Takeaway
Before solving, ask: which variable am I solving for? Pick the correct rearrangement.
Write the three forms on a sticky note until they're automatic.

Unit Conversion: The Hidden Trap

You'd be surprised how many candidates lose marks because they use km/h with time in minutes. The rule: convert everything to the same unit system before plugging into the formula.

Key conversions
  • km/h to m/s: multiply by 5/18 (or 1000/3600)
  • m/s to km/h: multiply by 18/5
  • minutes to hours: divide by 60
  • hours to minutes: multiply by 60
  • km to meters: multiply by 1000

Example: A train moves at 72 km/h. Express speed in m/s: 72 × (5/18) = 20 m/s.

Common mistake: use 5/18 but apply it the wrong way — multiplying when you should divide. Remember: m/s is a smaller number than km/h, so you multiply by 5/18 to go down.

Production Insight
A pilot used knots for speed but statute miles for distance — the unit mismatch caused an unscheduled landing.
Always validate units with dimensional analysis before any calculation.
Rule: Dimensional consistency is not optional — ever.
Key Takeaway
Always convert units before plugging into the formula.
Use 5/18 for km/h ↔ m/s. Double-check by asking: should the number go up or down?

Relative Speed: When Two Objects Move

When two objects move along the same line, the distance between them changes at their relative speed: - Moving toward each other: relative speed = speed1 + speed2 - Moving in the same direction: relative speed = |speed1 - speed2|

Classic problem: Two trains of lengths 150 m and 200 m move toward each other at 60 km/h and 40 km/h. How long to fully pass each other?

Step 1: Convert speeds to m/s. 60 km/h = 60 × 5/18 = 16.67 m/s. 40 km/h = 11.11 m/s. Step 2: Relative speed = 16.67 + 11.11 = 27.78 m/s. Step 3: Total distance to cover = 150 + 200 = 350 m. Step 4: Time = 350 / 27.78 ≈ 12.6 seconds.

Many forget to add the lengths. Always include both lengths when objects pass each other.

Production Insight
Autonomous vehicles compute Time to Collision as distance / relative speed.
A car ahead brakes: if the system adds speeds instead of subtracting, it can miss the real danger.
Rule: Direction dictates operation — opposite add, same subtract.
Key Takeaway
Distance between moving objects changes at relative speed.
Add speeds when moving toward, subtract when same direction.

Average Speed: Don't Average Speeds

The most common trap in TSD: taking the arithmetic mean of two speeds to get average speed. That is almost always wrong.

Correct: Average speed = Total distance / Total time.

Example: A car goes 60 km/h for 2 hours, then 40 km/h for 3 hours. Wrong average: (60 + 40)/2 = 50 km/h. Correct: Total distance = (60×2) + (40×3) = 120 + 120 = 240 km. Total time = 2 + 3 = 5 hours. Average speed = 240/5 = 48 km/h.

The harmonic mean (2ab/(a+b)) gives the correct answer only when distances are equal. In this case distances are not equal (120 vs 120? Actually they are equal in this example, 120 each, so harmonic mean would work but that's a special case. Better to stick to total distance / total time.

Production Insight
Logistics routing used arithmetic mean: 20 km/h + 80 km/h divided by 2 = 50 km/h.
Correct average (harmonic mean for equal distances) was 32 km/h — ETAs off by 56%.
Rule: Total distance / total time is the only safe average.
Key Takeaway
Average speed = total distance / total time.
Never use arithmetic mean of speeds unless time intervals are equal.

Boats, Streams, Trains, and Circular Tracks

Real-world TSD extensions test your ability to handle multiple frames of reference.

Boats and Streams: - Downstream speed = boat speed + stream speed - Upstream speed = boat speed - stream speed

Trains passing objects: - Passing a stationary object: distance = train length - Passing a moving object: distance = train length + object length (if moving opposite) or difference (if same direction)

Circular tracks: - Time for two runners to meet when running in same direction = track length / (relative speed) - When running opposite directions = track length / (sum of speeds)

These variations are the bread and butter of interview aptitude rounds. There's nothing new in them — it's still D = S × T with adjusted 'distance' and 'speed' definitions.

Production Insight
Race car telemetry computes lap times using relative speed to the car ahead.
Miscounting direction (same vs opposite) changes pit strategy and loses positions.
Rule: Always identify reference frame — ground or relative to another object.
Key Takeaway
Circular track: time to meet = track length / relative speed.
Train vs object: total distance = sum of lengths when passing each other.

Interview Strategy: How to Attack Any TSD Problem in Under 30 Seconds

In aptitude rounds, time pressure is the real test. Here's a repeatable framework:

  1. Identify the scenario: single object, two objects (relative speed), average speed, or special case (boats, trains, circular).
  2. Write down known variables and their units. Convert all to consistent units immediately.
  3. Select the correct formula variant. For relative speed, determine direction.
  4. Solve step by step — interviewers want clear reasoning, not fast mental math.
  5. Double-check: does the answer make sense? (e.g., time shouldn't be negative, speed should be less than absurd.)

Practice this sequence until it's automatic. Most candidates lose marks not because they don't know the formulas but because they rush and skip unit conversion or misidentify the scenario.

Production Insight
In real-time ETA engines, the same framework applies: identify input types, convert units, pick the right formula. A financial analytics platform once misclassified a relative speed problem as a single object — their billing estimates were off by 40%.
Always classify the problem type before touching the formula.
Rule: Classification before calculation.
Key Takeaway
Classify the scenario first — it dictates the formula.
Convert units before any arithmetic.
Show your reasoning step-by-step; interviewers value clarity over speed.

The Catch-Up Problem: When One Object Starts Later

Most juniors screw this up because they treat both objects as independent. They aren't. When a train leaves at 10:00 AM and another leaves at 10:15 AM, the second train has to cover the same distance in less time. The key insight: the distance each travels from the point where the chase starts is identical. Set D₁ = D₂, write the time with a known offset, and solve for the unknown. This pattern appears in all time-speed-distance problems where one object leaves late or has a head start. Don't write two separate equations. Write one: S₁ × T = S₂ × (T - offset). That single equation contains the entire problem.

CatchUpProblem.javaJAVA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// io.thecodeforge
public class CatchUpProblem {
    public static void main(String[] args) {
        double speed1 = 60.0; // km/h, leaves at 10:00
        double speed2 = 80.0; // km/h, leaves at 10:15
        double offsetHours = 15.0 / 60.0; // 15 minutes = 0.25 hours
        
        // distance1 = 60 * t, distance2 = 80 * (t - 0.25)
        // set equal: 60t = 80(t - 0.25)
        double t = (speed2 * offsetHours) / (speed2 - speed1);
        double meetingDistance = speed1 * t;
        
        System.out.printf("Meeting time: %.2f hours after 10:00%n", t);
        System.out.printf("Distance from start: %.2f km%n", meetingDistance);
    }
}
Output
Meeting time: 1.00 hours after 10:00
Distance from start: 60.00 km
Production Trap:
Never subtract speeds for catch-up problems. You need the time offset baked into the distance equality. If you subtract speeds, you lose the start-time delta and get garbage.
Key Takeaway
For catch-up, write D₁ = D₂ with time offset directly inside the equation. One equation, one unknown.

The Overtaking Problem: Relative Position, Not Relative Speed

Here's where most production code fails: overtaking problems ask 'how long to close a gap?' not 'when do they meet?' The gap is the distance between two objects at a given moment. If a car is 2 km ahead, and you're faster by 10 km/h, you close that gap at the difference in speeds. Treat the gap as a single distance to be covered at relative speed. Never compute individual times and try to reason about when they align—that's fragile. Use one equation: time = initial gap / (speed₂ - speed₁). Simple. Test it. Ship it.

OvertakingTracker.javaJAVA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// io.thecodeforge
public class OvertakingTracker {
    public static void main(String[] args) {
        double speedSlower = 50.0; // km/h
        double speedFaster = 70.0; // km/h
        double initialGapKm = 2.0; // km ahead
        
        double relativeSpeed = speedFaster - speedSlower;
        double hoursToOvertake = initialGapKm / relativeSpeed;
        double minutesToOvertake = hoursToOvertake * 60;
        
        System.out.printf("Time to overtake: %.1f minutes%n", minutesToOvertake);
        System.out.printf("Distance traveled by faster: %.2f km%n", speedFaster * hoursToOvertake);
    }
}
Output
Time to overtake: 6.0 minutes
Distance traveled by faster: 7.00 km
Principle:
Overtaking is always gap / relative speed. If the gap is decreasing, you're faster. If increasing, you're slower. The sign tells the story.
Key Takeaway
Overtaking time = initial gap / (your speed - their speed). Don't overthink it.

The Meeting Point: Two Objects, One Distance, Two Times

Meeting point problems are the inverse of catch-up. Two objects start at opposite ends and move toward each other. The sum of their distances equals the total path length. Critical insight: time is the same for both when they meet. Write D_total = S₁ × T + S₂ × T. This collapses to T = D_total / (S₁ + S₂). Every meeting problem—trains, runners, cars on a highway—boils down to this. The moment you see 'meet in the middle', think sum of speeds, not subtraction. I've seen four-hour debugging sessions fixed by replacing two separate timers with one addition.

MeetingPointSolver.javaJAVA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// io.thecodeforge
public class MeetingPointSolver {
    public static void main(String[] args) {
        double speedA = 40.0; // km/h from east
        double speedB = 60.0; // km/h from west
        double totalDistance = 100.0; // km
        
        double timeToMeet = totalDistance / (speedA + speedB);
        double distanceFromEast = speedA * timeToMeet;
        
        System.out.printf("Meeting time: %.2f hours%n", timeToMeet);
        System.out.printf("Distance from east start: %.2f km%n", distanceFromEast);
    }
}
Output
Meeting time: 1.00 hours
Meeting distance from east start: 40.00 km
Production Trap:
Never assign different time variables for meeting problems. Both objects share the same T. If you use T₁ and T₂, you've already failed. The unit tests will remind you painfully.
Key Takeaway
Meeting point: T = total distance / sum of speeds. One variable. Done.
● Production incidentPOST-MORTEMseverity: high

The 10-Minute Delay That Added Two Hours

Symptom
Planned arrival times consistently showed early, then drivers reported delays. Discrepancy grew with more speed variations.
Assumption
Average speed can be computed by adding speeds and dividing by number of segments — i.e., arithmetic mean is correct.
Root cause
The system calculated average speed as (s1 + s2) / 2 instead of total distance / total time. When speeds differed, the error compounded.
Fix
Rewrite the routing engine to compute average speed using weighted time: total distance / sum(time per segment). Validate with a manual test.
Key lesson
  • Never average speeds you didn't weigh by time.
  • Always verify ETA algorithms against real trip logs before deploying.
  • The correct average speed formula is: total distance ÷ total time.
Production debug guideWhen your travel time estimates are consistently wrong, check these symptoms and actions.4 entries
Symptom · 01
Estimated arrival time is off by more than 30%
Fix
Verify that all speeds are in the same unit. Convert km/h to m/s by multiplying by 5/18. Convert minutes to hours by dividing by 60.
Symptom · 02
Average speed seems too high or too low
Fix
Check if you're using arithmetic mean of speeds. Recompute using total distance / total time. For multi-segment trips, sum distances and sum times separately.
Symptom · 03
Two objects passing each other: time computed is too short
Fix
Did you forget to add the lengths of both objects? The total distance to clear is length1 + length2. Relative speed is sum of speeds when moving opposite directions.
Symptom · 04
Train crosses a platform: time off
Fix
Remember the train must cover its own length plus platform length. Distance = train length + platform length. Speed in same units.
TSD Formula Variants Compared
ConceptKey FormulaCommon PitfallProduction Use Case
Single ObjectD = S × TMismatched units (km/h with minutes)GPS ETA for single route
Relative Speed (toward)S_rel = S1 + S2Forgetting to add lengthsCollision avoidance in autonomous vehicles
Relative Speed (same dir)S_rel = |S1 - S2|Subtracting wrong wayOvertaking decision in cruise control
Average SpeedS_avg = D_total / T_totalUsing arithmetic mean of speedsLogistics ETA across mixed-speed segments

Key takeaways

1
TSD models any moving object
know two variables, find the third.
2
Unit conversion first, formula second
always convert km/h to m/s (×5/18).
3
Practice under timed pressure
interview speed matters as much as accuracy.
4
Three formula rearrangements
D=ST, S=D/T, T=D/S. Master which to apply when.
5
Unit conversion is non-negotiable
convert everything to consistent units before calculating.
6
Relative speed is the key to multi-object problems. Add or subtract based on direction.
7
Average speed is always total distance / total time. Never average the speeds.
8
Draw a simple diagram for complex scenarios
it clarifies which distance and speed to use.

Common mistakes to avoid

6 patterns
×

Memorising formulas before understanding the concept

Symptom
You can recite D = S × T but freeze when a problem gives you time and distance and asks for speed.
Fix
Practice converting between the three forms until you can derive any from any two. Use the triangle mnemonic: cover the variable you want, the remaining two show the operation.
×

Skipping practice and only reading theory

Symptom
You understand the explanations but miss half the marks in timed tests.
Fix
Solve at least 10 problems per pattern. Use a timer — interview pressure is real. Track which conversions you get wrong.
×

Using km/h with minutes without converting

Symptom
You apply time in minutes directly into the formula and get a distance that's obviously wrong (e.g., 1800 km instead of 30 km).
Fix
Always convert minutes to hours by dividing by 60 before plugging into D = S × T if speed is in km/h. Better: convert everything to the same unit system at the start.
×

Averaging speeds arithmetically

Symptom
You compute (60 + 40)/2 = 50 km/h as average speed, but the actual average is 48 km/h.
Fix
Use total distance / total time. For two speeds over equal distances, use harmonic mean (2ab/(a+b)). For anything else, compute total distance and total time explicitly.
×

Forgetting to add lengths when trains pass

Symptom
You compute passing time as 200 m / relative speed, but the correct distance is 200 + 150 = 350 m.
Fix
When two objects pass each other, the total distance is the sum of their lengths. Draw a diagram if needed.
×

Misidentifying reference frame — using ground speed when you need relative speed

Symptom
In boat-stream problems, using boat speed in still water as absolute speed instead of accounting for current leads to wrong crossing times.
Fix
Always ask: 'Is this speed relative to ground or relative to another object?' For boats, downstream = boat + stream; upstream = boat - stream.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
A car travels from town A to town B at 60 km/h and returns from B to A a...
Q02SENIOR
Two trains of lengths 150 m and 200 m are moving towards each other at 6...
Q03SENIOR
A boat travels downstream 30 km in 2 hours. The same distance upstream t...
Q04SENIOR
Two runners start from the same point on a circular track of length 400 ...
Q05SENIOR
A train passes a stationary man in 9 seconds and a platform 120 m long i...
Q06SENIOR
A car overtakes a truck traveling at 40 km/h in 10 seconds. The car is 4...
Q01 of 06JUNIOR

A car travels from town A to town B at 60 km/h and returns from B to A at 40 km/h. What is the average speed for the entire trip?

ANSWER
The average speed is NOT (60+40)/2 = 50 km/h. Since the distances are equal, use harmonic mean: 2 60 40 / (60+40) = 4800 / 100 = 48 km/h. Or compute total distance: 2d, total time: d/60 + d/40 = (2d/120 + 3d/120) = 5d/120 = d/24. Then average speed = 2d / (d/24) = 48 km/h.
FAQ · 7 QUESTIONS

Frequently Asked Questions

01
What is Time Speed Distance Problems in simple terms?
02
Why do I keep getting wrong answers when I use D = ST directly?
03
How do I tell when to use relative speed?
04
What's the fastest way to solve TSD problems in an interview?
05
Is the harmonic mean always correct for average speed?
06
How do I handle problems where speed changes during the journey?
07
What's the difference between two trains passing toward each other vs one overtaking the other?
N
Naren Founder & Principal Engineer

20+ years shipping production code across the stack, with years spent interviewing engineers. Written from production experience, not tutorials.

Follow
Verified
production tested
May 24, 2026
last updated
1,554
articles · all by Naren
🔥

That's Aptitude. Mark it forged?

6 min read · try the examples if you haven't

Previous
Profit and Loss Problems
4 / 14 · Aptitude
Next
Probability Problems