HardPro challengePython

asyncio.gather — Run Tasks Concurrently

PythonAsyncConcurrency

Implement solve(delays) that:
1. Creates one coroutine per item in delays — each coroutine waits delay seconds then returns delay * 10.
2. Runs all coroutines concurrently with asyncio.gather.
3. Returns the list of results in the same order as the input.

Examples

  • solve([0.1, 0.2, 0.05])[1, 2, 0] *(delays × 10, rounded down)*
  • solve([0.3])[3]

Constraints

  • Use asyncio.gather — do not run coroutines sequentially.
  • Results must preserve input order (gather guarantees this).
  • Total wall-clock time should be ≈ max(delays), not sum(delays).

Sample tests

Test #1Three tasks, results in input order
Input: [[0.1,0.2,0.05]]
Output: [1,2,0]
Test #2Single task
Input: [[0.3]]
Output: [3]
Test #3Zero delays
Input: [[0,0]]
Output: [0,0]