Thanks for the quick reply ozo
But i dont see any diff between A and B...
But A seems to do it...
Thanks
-Oli
Main Topics
Browse All TopicsHello
Im asking this question here (and not in the Math/Science section) because i need the code (i would prefer Java or C/C++) that will generate a sport team schedule following these rules:
case a:
- There are 30 teams
- Each teams playing 1 time against all other team (so 29 games per team)
- Cannot play twice against the same team
- Schedule must be random (if schedule is twice in a row, the results will differ)
case b:
- There are 30 teams
- Each teams playing 2 times against all other team (so 58 games per team)
- Schedule must be random (if schedule is twice in a row, the results will differ)
Big thanks to all who will try to help me out here.
Thanks
-Oli
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
With the second shuffle of the teams the second half schedule should be different from the first half.
That should work unless you want it to be possible for teams 1 & 2 to be able to play back to back games or twice at any time in the season rather than once in the first 29 games and the second game in the last 29 games.
mlmcc
Business Accounts
Answer for Membership
by: ozoPosted on 2004-09-21 at 07:17:55ID: 12112443
#include <stdlib.h> ],teams[(2 8-s+r)%29+ 1]); ],teams[(2 8-s+r)%29+ 1]);
char *teams[]={"team1", "team2", "team3", "team4", "team5", "team6", "team7", "team8", "team9", "team10", "team11", "team12", "team13", "team14", "team15", "team16", "team17", "team18", "team19", "team20", "team21", "team22", "team23", "team24", "team25", "team26", "team27", "team28", "team29", "team30"};
char *games[15];
void shuffle(char *array[],int n){
int i;
for( i=n; --i; ){
int j = rand() % (i+1);
char *t = array[i];
array[i] = array[j];
array[j] = t;
}
}
main(){
int r,s,t;
for( s=0;s<15; s+=1 ){ games[s] = (char *)malloc(20); }
srand(time());
printf("a\n");
shuffle(teams,30);
for( r=0;r<29;r++ ){
for( s=0;s<15;s++ ){
sprintf(games[s],"%s vs. %s",teams[s?(r+s-1)%29+1:0
}
shuffle(games,15);
for( s=0;s<15;s++ ){
printf("%s\n",games[s]);
}
printf("\n");
}
printf("b\n");
shuffle(teams,30);
for( r=0;r<29;r++ ){
for( s=0;s<15;s++ ){
sprintf(games[s],"%s vs. %s",teams[s?(r+s-1)%29+1:0
}
shuffle(games,15);
for( s=0;s<15;s++ ){
printf("%s\n",games[s]);
}
printf("\n");
}
}