Hard
Work in Batches
Process the input numbers in batches of k: for each batch, run
square(x) for every item at the same time with asyncio.gather (each awaits a tiny sleep), print batch N: results, and only then start the next batch.Input
Numbers on one line; then k.
Output
Lines.
Sample 1
Input
1 2 3 4 5 2
Output
batch 1: 1 4 batch 2: 9 16 batch 3: 25
Sample 2
Input
7 3
Output
batch 1: 49
Output appears here