Skip to content

Instantly share code, notes, and snippets.

@vhsu
Created October 31, 2018 18:47
Show Gist options
  • Save vhsu/ae9981efdf880939fa398f928bb8d079 to your computer and use it in GitHub Desktop.
Save vhsu/ae9981efdf880939fa398f928bb8d079 to your computer and use it in GitHub Desktop.
combiLoopOptimizer
//This is used in findBalancedSets function, to reduce processing time for large sets of combinations
function combiLoopOptimizer(combinationsR, playerNames) {
var start = 0;
var skipRanges = [];
skipRanges.length = combinationsR[0].length;
for (var i = playerNames.length; i >= 0; i--) {
//size of range to skip
var temp = Math.floor(getTotalCombinations(i - 1, teamsize - 1));
//start of range to skip
var endTemp = start + temp + 1;
skipRanges.fill(start, start, endTemp)
start = start + temp
}
return skipRanges
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment