This question evaluates datetime parsing, event-stream reconstruction, state-machine reasoning for order lifecycles, and aggregation of timed intervals to compute compensation, including handling unordered timestamps, timezones, rounding, and malformed transitions.
You are given a list of delivery-order event records for a single dasher. Each record contains:
order_id
event_type
in
{CREATED, ACCEPTED, PICKED_UP, DELIVERED, CANCELED}
timestamp
as a datetime string (may include timezone; events may not be pre-sorted)
Rules:
ACCEPTED
and ending at the first of
DELIVERED
or
CANCELED
.
DELIVERED
without
ACCEPTED
) or define a reasonable handling; your solution should be explicit.
Task: Implement a function that parses the datetimes correctly, reconstructs each order’s state transitions, and returns the total pay.