Token bucket rate limiter
Your task
Simulate a token-bucket rate limiter. The bucket holds at most 'burst' tokens and refills at 'rate' tokens per second, capped at burst. Requests arrive at the given non-decreasing integer 'timestamps' (seconds). The bucket starts full. For each request, first refill by elapsed*rate since the previous request (clamped to burst), then admit the request if at least one token is available (consuming one) else deny. Return a list of booleans, one per request. An empty timestamp list returns an empty list.
Examples
token_bucket(rate: int, burst: int, timestamps: list[int]) -> list[bool]Example 1
Input
token_bucket(1, 2, [0, 0, 0])Output
[True, True, False]