A token bucket holds up to capacity tokens and starts full. Tokens refill continuously at rate tokens
per second (fractions allowed), never exceeding capacity. Each request takes one token if at least one is
available; otherwise it is rejected.
Given request timestamps in seconds (non-decreasing), return a list of booleans: allowed or not.
Implement token_bucket. Input: capacity: int, rate: float, timestamps: list[float]. Returns: list[bool].
def token_bucket(capacity: int, rate: float, timestamps: list[float]) -> list[bool]:
return [True] * len(timestamps)
Run executes the public tests. Submit grades against public and hidden tests.
A token bucket holds up to capacity tokens and starts full. Tokens refill continuously at rate tokens
per second (fractions allowed), never exceeding capacity. Each request takes one token if at least one is
available; otherwise it is rejected.
Given request timestamps in seconds (non-decreasing), return a list of booleans: allowed or not.
Implement token_bucket. Input: capacity: int, rate: float, timestamps: list[float]. Returns: list[bool].
def token_bucket(capacity: int, rate: float, timestamps: list[float]) -> list[bool]:
return [True] * len(timestamps)
Run executes the public tests. Submit grades against public and hidden tests.