runtime
494 / 500
question 494 Production Readiness Capstone · medium

Quarantine impossible trips

The TLC export contains trips that can't be real: negative totals, a dropoff before the pickup, a thousand-mile ride across town. Split a night's trips into good ones and quarantined ones, each quarantined trip with the first rule it breaks.

Functionsplit_trips(trips) → (good, quarantined)
Rules, in ordertotal_amount is not negative ("negative total"); trip_distance_miles is from 0 to 200 ("impossible distance"); dropoff_at is not before pickup_at ("dropoff before pickup")
Timestexts like 2025-01-15 00:12:47; this format compares correctly as text
Returnsgood: the trips that break no rule, in order; quarantined: (trip_id, reason) tuples, in order
Rulethe trips are not changed

Loading your progress…

Quarantine impossible trips — Python practice · Runtime