Skip to content

Instantly share code, notes, and snippets.

@lloc
Created December 17, 2017 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloc/bd5dc82af717239ee19e388b74c3e1ac to your computer and use it in GitHub Desktop.
Save lloc/bd5dc82af717239ee19e388b74c3e1ac to your computer and use it in GitHub Desktop.
<?php
function getRoundRobinTable ($n) {
$result = array ();
if ($n % 2 == 0) {
for ($r = 0; $r < $n - 1; $r++) {
for ($i = 0; $i < $n / 2; $i++) {
$result[$r][] = array (
($i == 0 ? 0 : ($r + $i) % ($n - 1) + 1),
($n - 1 + $r - $i) % ($n - 1) + 1,
);
}
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment