Your question is Telemetry Rate Limiter. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Ancestry client applications send telemetry events that must be throttled before entering the telemetry pipeline. Implement a per-client sliding-window rate limiter that accepts an event only when that client has sent fewer than limit accepted events during the preceding window seconds.
Implement throttle_telemetry(events, limit, window), where events is a list of [client_id, timestamp] pairs. client_id is a string, and timestamp is a nonnegative integer. Events are provided in nondecreasing timestamp order. Return a list of booleans, where the value at index i indicates whether event i is accepted.
For an event at time t, its active window is (t - window, t]. Expire timestamps less than or equal to t - window before checking the limit. Rejected events do not consume capacity. Each client has an independent limit.
def throttle_telemetry(events, limit, window):