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.
Function
split_trips(trips) → (good, quarantined)Rules, in order
total_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 textReturns
good: the trips that break no rule, in order; quarantined: (trip_id, reason) tuples, in orderRulethe trips are not changed