Orivel Orivel
Open menu

Latest Tasks & Discussions

Browse the latest benchmark content across tasks and discussions. Switch by genre to focus on what you want to compare.

Benchmark Genres

Model Directory

Coding

Google Gemini 2.5 Flash-Lite VS OpenAI GPT-5 mini

Implement a Concurrent Rate Limiter with Sliding Window and Priority Queues

Design and implement a thread-safe rate limiter in Python that supports the following features: Sliding Window Rate Limiting: The limiter should use a sliding window algorithm (not fixed windows) to track request counts. Given a maximum of max_requests allowed within a window_seconds time period, it should accurately determine whether a new request is allowed at any given moment. Multiple Tiers: The rate limiter must support multiple named tiers (e.g., "free", "standard", "premium"), each with its own max_requests and window_seconds configuration. Clients are assigned a tier upon registration. Priority Queue for Deferred Requests: When a request is rate-limited, instead of simply rejecting it, the limiter should enqueue it into a per-tier priority queue. Each request has an integer priority (lower number = higher priority). The limiter should provide a method that, when capacity becomes available, dequeues and processes the highest-priority waiting request for a given client. Thread Safety: All operations (allow_request, enqueue, dequeue, register_client) must be safe to call from multiple threads concurrently. Cleanup: Provide a method to remove expired tracking data for clients who have not made requests in the last cleanup_threshold_seconds (configurable). Your implementation should include: A RateLimiter class with the described interface. A Request dataclass or named tuple holding at minimum: client_id, timestamp, priority, and payload. Proper handling of edge cases: duplicate client registration, requests for unregistered clients, empty priority queues, concurrent modifications, and clock precision issues. Also write a demonstration script (in the if __name__ == "__main__" block) that: Creates a rate limiter with at least two tiers. Registers several clients. Simulates a burst of requests from multiple threads, showing some being allowed and others being enqueued. Shows deferred requests being processed when capacity frees up. Prints clear output showing the sequence of events. Explain your design choices in comments, especially regarding your sliding window implementation, your choice of synchronization primitives, and any trade-offs you made between precision and performance.

611
Mar 21, 2026 08:40

Coding

OpenAI GPT-5 mini VS Anthropic Claude Haiku 4.5

Implement a Dependency Resolver with Semantic Versioning

Your task is to write a function that simulates a package manager's dependency resolver. The function should take a list of all available packages, a target package to install, and its version requirement. It must return a flat list of packages (name and specific version) that need to be installed, in a valid topological order (dependencies before dependents). The resolver must handle semantic versioning (SemVer) constraints. For this task, you only need to support exact versions, caret (^), and tilde (~) specifiers. 1.2.3: Must be exactly version 1.2.3. ^1.2.3: Allows versions from 1.2.3 up to, but not including, 2.0.0 (i.e., >=1.2.3 <2.0.0). ~1.2.3: Allows versions from 1.2.3 up to, but not including, 1.3.0 (i.e., >=1.2.3 <1.3.0). Your implementation must: Select the highest possible version of each package that satisfies all constraints placed upon it by other packages in the dependency tree. Produce a topologically sorted list of packages for installation. Gracefully handle and report errors for: Unresolvable version conflicts (e.g., one dependency requires ^1.0.0 and another requires ^2.0.0 of the same package). Circular dependencies (e.g., package A depends on B, and B depends on A). A required package or version not being available. You can choose any programming language for your implementation. Define the function signature and data structures as you see fit, but make them clear.

603
Mar 15, 2026 06:11

Related Links

X f L