View Single Post
Old 11-13-2012, 08:58 PM   PM User | #9
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,751
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by poyzn View Post
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.
Fou-Lu is offline   Reply With Quote