Workspace/Coding labs
Loading progress

Aggregate with an explicit lateness policy

Intermediate65 min

Process arrivals in listed order. Use nonnegative integer event time and signed integer value. Before each unique event, compute watermark as maximum accepted event time minus lateness; reject an event as late when its time is strictly below that prior watermark. Equality is accepted. Accepted events join half-open windows via time // width * width. Identical IDs are ignored, conflicting ID payloads fail, and late IDs are returned for audit. This is a simple local max-seen estimator, not a distributed watermark implementation; timestamp plausibility checking is an extension.

Your task

  1. Complete the starter function using the contract above.
  2. Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
  3. Run tests to record your result, then compare with the explained reference solution.

Examples

EXAMPLE 1

Inputtimes 3,12,8,21,6; width 10; lateness 5

OutputLast event late; windows 0,10,20 populated

Time 8 remains within the prior watermark; time 6 does not.
EXAMPLE 2

Inputmaximum 10, lateness 5, next time 5

OutputAccepted

The rejection boundary is strict less-than.
solution.pyPython 3.12