[Solved] Create coalition combinations with Javascript array
You could use a search and test if the count is smaller then the max items and for the sum of seats. function getCombinations(array, sum, max) { function fork(i, t) { var s = t.reduce(function (r, a) { return r + a[2]; }, 0); if (s >= sum) { result.push([s, t.map(function (a) { return [a[1], … Read more