All problems
Coroutine Scheduler Round Robin
Problem
Schedule coroutines with a round-robin time slice.
tasks is a list of [name, work] and quantum is the maximum work units each task runs per turn. A task that still has work after its slice goes to the back of the queue.
Return the completion order of task names.
Hint
A task completing exactly on its slice boundary still finishes that turn.
Test cases
case 1
in: [[["a",5],["b",3]],2]
expected: ["b","a"]
case 2
in: [[["x",2]],5]
expected: ["x"]
case 3
in: [[],2]
expected: []
case 4
in: [[["a",1],["b",1]],1]
expected: ["a","b"]
Starter codePython
def round_robin(tasks, quantum):
# Your code here
pass4 test cases · run your code against them in the editor