NumPy allowed · plain Python earns 10 bonus points
Simulate the industry-standard Token Bucket traffic-shaping algorithm for API throttling and LLM rate limiting.
Implement simulate_token_bucket(requests, rate, capacity): the bucket starts at full capacity. At each arrival timestamp t, compute replenished tokens (t - last_time) * rate (capped at capacity). If tokens >= 1.0, consume 1.0 and record True, otherwise reject and record False.
simulate_token_bucket(requests: list[float], rate: float, capacity: float) -> list[bool]