Run asynchronous operations with an explicit concurrency limit.

Prototype: async def double_later(value) yields control using await asyncio.sleep(0) and returns value * 2 for an integer input.

Final: async def async_map(values, operation, limit=2) calls async callable operation(value) exactly once per value and returns results in input order. Limit active operation calls to at most limit with an asyncio.Semaphore. Schedule independent work concurrently; with at least two values and limit 2, two operations must be able to enter before either completes. limit is an integer; values below 1 raise ValueError, even on empty input. Empty input gives []. Do not mutate the input. On any operation failure or caller cancellation, cancel and await unfinished sibling tasks before propagating the original failure or cancellation. Do not leave background tasks running. Inputs are finite lists, so one task per value is acceptable. Use no real network or blocking sleep. Await this API in browser code; main.py manages its own loop for native CLI tests.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.