The brief
Normalize a batch of timestamped events, remove equivalent replays and sort them by the actual instant. Events with equal timestamps need a consistent tie-breaker. Conflicting replays and timestamps without a timezone must be rejected.
Why this case matters
Events can arrive late, be replayed or use different timezone offsets. This exercise produces one repeatable timeline from a batch and makes the rules for duplicates and tied times explicit.
Input and output contract
The accepted fields and returned values are defined before the implementation is checked.
| Input field | Requirement |
|---|---|
id | A non-empty event ID used to identify a replay. |
at | An ISO timestamp with an explicit timezone offset or Z. |
type | A non-empty event type; a replay must keep the same type. |
| Output field | Meaning |
|---|---|
id | One record for each distinct, non-conflicting event ID. |
at | The event instant in UTC, with six decimal places and a Z suffix. |
type | The original event type. Records are sorted by instant, then ID. |
An input-to-output example
This example was checked against the included Python reference implementation.
Input records
[
{
"id": "paid",
"at": "2026-01-01T10:30:00+01:00",
"type": "paid"
},
{
"id": "created",
"at": "2026-01-01T10:00:00+01:00",
"type": "created"
},
{
"id": "created",
"at": "2026-01-01T09:00:00Z",
"type": "created"
},
{
"id": "queued",
"at": "2026-01-01T09:00:00Z",
"type": "queued"
}
]Returned result
[
{
"id": "created",
"at": "2026-01-01T09:00:00.000000Z",
"type": "created"
},
{
"id": "queued",
"at": "2026-01-01T09:00:00.000000Z",
"type": "queued"
},
{
"id": "paid",
"at": "2026-01-01T09:30:00.000000Z",
"type": "paid"
}
]10:00 at +01:00 and 09:00 at Z describe the same instant, so the repeated created event collapses to one record. created and queued share a time and are ordered by ID; paid follows at 09:30 UTC.
A case that should fail
A timestamp such as 2026-01-01T09:00:00 has no timezone and is rejected. Reusing an ID with a different event type is also rejected.
How it works
The implementation parses timezone-aware timestamps, converts them to UTC and deduplicates by event ID. Ordering uses the timestamp followed by the ID, so rearranging the input does not change the result.
- Read the event timestamps
Check the required fields and parse each timestamp. Reject invalid dates and timestamps that do not identify a timezone.
- Normalize and deduplicate
Convert timestamps to UTC. Treat equivalent instants and matching event types as the same replay, even when their original offsets differ.
- Sort the final timeline
Order accepted events by the actual instant. When instants match, sort by ID to make the result stable.
What we checked
The verifier covers offset conversion, conflicting replays, missing fields, invalid dates, empty batches and microsecond precision. It checks that rearranging the same input still produces the same timeline.
| Check | Reference result |
|---|---|
| Ordering across timezone offsets | Passed |
| Equivalent replays deduplicated | Passed |
| Conflicting replays rejected | Passed |
| Timezone-free timestamps rejected | Passed |
| Invalid dates rejected | Passed |
| Empty input | Passed |
| Missing fields rejected | Passed |
| Stable ordering for tied times | Passed |
| Microsecond precision | Passed |
| Input-order independence | Passed |
The reference implementation passed all 10 checks. The verifier also rejected a deliberately empty implementation. This confirms that the checks can detect that incorrect submission; it does not prove that every possible incorrect solution will be caught.
Run it yourself
Download and unzip the package. From its folder, run:
python verify.pyTo check another implementation, use python verify.py path/to/candidate.py. No external packages or network access are required.
Scope and limitations
This example operates on a batch in memory. It does not implement streaming persistence or a distributed event system. Its checks are finite and are not a measurement of AI model performance.
The recorded run used Python 3.12.14. A Dockerfile is included for convenience, but Docker was not used for the published verification run and its base image is not digest-pinned.