Round-Robin Assignment

This is how simple load balancers work: the first task goes to the first server, the next task to the second server, and so on in a cycle. Given the number of tasks tasks and the number of servers servers, return a list of length tasks showing which server index handles each task. Server indices go from 0 to servers - 1. If there are no tasks, return an empty list.

Примеры

Ввод
5, 2
Вывод
[0, 1, 0, 1, 0]
Ввод
0, 3
Вывод
[]
Ввод
3, 3
Вывод
[0, 1, 2]

Нужно реализовать

def round_robin(tasks, servers):

Теги

arraylistsmath
PostgreSQLv16

Aquí aparecerá el resultado de la ejecución del código

Visible tests
1
Input
5, 2
Expected[0,1,0,1,0]
2
Input
0, 3
Expected[]
3
Input
3, 3
Expected[0,1,2]
4
Input
4, 1
Expected[0,0,0,0]
5
Input
7, 3
Expected[0,1,2,0,1,2,0]
6
Input
1, 3
Expected[0]
Focus radio
Paused · SomaFM · Fluid