Created
May 18, 2021 12:18
-
-
Save cngeru/8815170357279882e70d3657d468f255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var users = ["a","b","c"]; | |
var tasks = 10; | |
print(roundRobin(users,tasks)); | |
} | |
Map<N, List<T>> roundRobin<N, T>(List<N> names, int taskCount, T createTask(int number)) { | |
var tasks = [for (var i = 0; i < names.length; i++) <T>[]]; | |
for (var i = 0, j = 0; i < taskCount; i++) { | |
tasks[i % tasks.length].add(createTask(i + 1)); | |
} | |
return {for (var i = 0; i < names.length; i++) names[i]: tasks[i]}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment