<?php
function distribute($players) {
$ceil = ceil(count($players) / 2);
$floor = floor(count($players) / 2);
$ceilArray = array_chunk($players, $ceil);
$floorArray = array_chunk($players, $floor);
printf('%2d players. ceil %2d - %s'.PHP_EOL, count($players), $ceil, counts($ceilArray));
printf('%2d players. floor %2d - %s'.PHP_EOL, count($players), $floor, counts($floorArray));
}
function counts($array) {
$out = '';
foreach ($array as $dimension => $elements) {
$out .= sprintf('team%d: %d; ', $dimension, count($elements));
}
return $out;
}
distribute(range(1, 9));
distribute(range(1, 10));
distribute(range(1, 11));
- Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- 9 players. ceil 5 - team0: 5; team1: 4;
9 players. floor 4 - team0: 4; team1: 4; team2: 1;
10 players. ceil 5 - team0: 5; team1: 5;
10 players. floor 5 - team0: 5; team1: 5;
11 players. ceil 6 - team0: 6; team1: 5;
11 players. floor 5 - team0: 5; team1: 5; team2: 1;
preferences:
164.72 ms | 404 KiB | 236 Q