Bound asynchronous work and preserve ordering
Implement async bounded_squares(values, limit). Validate a list of exact integers and a positive exact integer limit. Square every value using local asynchronous tasks that yield once with asyncio.sleep(0). Return (squares_in_input_order, peak_active). At most limit tasks may be active inside the work region. Empty input returns ([], 0). No network, subprocess, sleeps with real delays, or user input are needed.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
EXAMPLE 1
Inputawait bounded_squares([3, -2, 0], 2)
Output([9, 4, 0], 2)
EXAMPLE 2
Inputawait bounded_squares([], 5)
Output([], 0)
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor