Hi,
I need to generate a list of fixtures for a league. I have x number of teams, numbered 1 to x.
Each team must play every other team ONCE, and each team must play no more than once per week.
I thought of an array $match[team1][team2] = $week
Spoken as: $team1 plays $team2 on week $week.
I used the following code to generate a list like:
1 vs 2
1 vs 3
..
1 vs n
2 vs 3
..
2 vs n
3 vs 4
..
3 vs n
..
etc.
But I have no idea how to generate the week numbers for the fixtures, so that no teams play 2ce in one week. Here is my current code.
while ($team1 < ($teamcount - 1)) {
if ($team2 < $teamcount) {
if ($team2 > $team1) {
/* if ((match[$team1][ANYTHING] == $week || match[ANYTHING][$team1] == $week) && (match[$team2][ANYTHING] == $week || match[ANYTHING][$team2] == $week)) {
$week++;
} else {
$match[$team1][$team2] = $week;
}
*/
}
$team2++;
} else {
$team2 = NULL;
$team1++;
}
}
Any ideas?