Quote:
Originally Posted by poyzn
PHP Code:
function schedule($teams = 10) {
$output = '<table cellpadding="5" border="1">';
for($i=1; $i<=$teams; $i++) {
$output .= '<tr>';
for($j=1; $j<=$teams; $j++) {
$output .= '<td>';
if($i == $j) {
$output .= ' - ';
} else {
$output .= "team $i vs. team $j";
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
return $output;
}
print schedule();
|
This has repetition in it. I'm under the impression repetition is not desired, so 1 should play 2 only once. That's easy to accommodate though.
Perhaps I'm still not "getting it" here. I still see that if you had 8 teams it would equate to 28 games played, not 10 (9 teams would be 36, 10 would be 45, etc). I'm not sure how you intend to shove the 8 teams into a 10 week period.