A simple pooling algorithm for group stages, ffa style tournaments or anything else that benefits from having seeds/weighted numbers split into fair groups.
Simply give it the number of players and an approximate group size (this may be reduced if all groups can't be filled), and it will return the fairest groups.
var group = ;;1 5 12 162 6 11 153 7 10 144 8 9 13;1 6 11 20 252 7 12 19 243 8 13 18 234 9 14 17 225 10 15 16 21
Best when two properties are satisfied:
numPlayers === groupSize*numGroups
groupSize % 2 === 0
You should always strive to satisfy the first condition.
groupSize is not even, then we cannot match up weighted pairs and the sum of seeds per group will differ by up to
groupSize is even, then the sum of seeds per groups are equal across all groups.
Minimal group size
You can check what your minimal group size will be by passing in the number of groups you want to split the players over:
group; // 4group; // 5group; // 4group; // general
If you have a pre-sorted array of seeded players, this can be passed to
group'a' 'e' 'l' 'p''b' 'f' 'k' 'o''c' 'g' 'j' 'n''d' 'h' 'i' 'm'
MIT-Licensed. See LICENSE file for details.