Created
February 1, 2021 09:10
-
-
Save bubnenkoff/43908b7d3a4864f9835f27d4f9ac0b25 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
main() { | |
genJobs(int activeWorkers, List<int> numbersOfAlreadyActiveJobs) { | |
final maxJobs = 16; | |
List<int> jobs = List<int>.generate(maxJobs, (i) => i + 1); | |
jobs.removeWhere((item) => numbersOfAlreadyActiveJobs.contains(item)); | |
final length = jobs.length; | |
var partSize = length ~/ activeWorkers; | |
if (length != partSize * activeWorkers) { | |
partSize++; | |
} | |
for (var i = 0; i < activeWorkers; i++) { | |
final start = i * partSize; | |
var end = start + partSize; | |
if (end > length) { | |
end = length; | |
} | |
print(jobs.sublist(start, end)); | |
} | |
} | |
genJobs(8, [7, 8, 3, 4]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment