algorithm

1. Member
Join Date
Dec 1969
Posts
45

## algorithm

I know this is not ASP related but i&#039;m still going to post my question... here it comes...<BR><BR>i&#039;m looking for a formula or algorithm for determining the matches to be played in a league. Like for example in a soccer season every team plays every other team twice in one season. Once at home and once away. I don&#039;t feel like doing this manually (just try it for 16 teams, you&#039;ll be amazed to find how hard it is) so if anyone has any extra information or usefull links, all help is appreciated<BR><BR>greetz<BR>Jo

2. Senior Member
Join Date
Dec 1969
Posts
973

## looks like 16!

looks like a factorial solution...<BR><BR>Team 1 plays the remaining 15 teams at home.<BR>Team two has already played Team 1 away so...<BR>Team two plays the remaining 14 teams at home....<BR><BR>and so on....

3. oli
Senior Member
Join Date
Dec 1969
Posts
3,961

## RE: algorithm

I think this could be adapted, it gives every combination of an array of numbers, but this could be the team names. The only change would be home and away, but I guess you just duplicate the list for the two types of matches.<BR><BR>http://63.236.18.31/forum/asp.asp?M=450582&T=450030&F=20&P=1<BR><BR>

4. Member
Join Date
Dec 1969
Posts
45

## RE: looks like 16!

try and write it out, it&#039;s realy not that simple!

5. oli
Senior Member
Join Date
Dec 1969
Posts
3,961

.

6. Member
Join Date
Dec 1969
Posts
45

## RE: algorithm

i think adapting that would be as much work as building the formula from scratch

7. Member
Join Date
Dec 1969
Posts
45

## RE: looks like 16!

i what order...<BR>what makes it so difficult is that a team can only play one match in one match day

8. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: looks like 16!

team 1 plays 15 games at home and 15 games away.<BR>team 2 plays 15 games at home and 15 games away. However, two of those games (against team 1) are already counted. So that&#039;s 28 games.<BR>team 3 plays 15 games at home and 15 games away. However, four of those games (against team 1 and 2) are already counted. So that&#039;s 26 games.<BR><BR>If there are 16 teams, they play:<BR>30+28+26+....0<BR>Which is ((2n-2)!), I think. Can someone else confirm that - brain hurts.<BR><BR>Craig.

9. Senior Member
Join Date
Dec 1969
Posts
973

## RE: looks like 16!

team 1 plays 15 games at home and 15 games away. <BR>team 2 plays 15 games at home and 14 games away<BR>team 3plays 15 games at home and 13 games away<BR><BR><BR>30,29,28.... ?

10. Senior Member
Join Date
Dec 1969
Posts
16,931

## Order?!

Order&#039;s not a problem.<BR><BR>Wait a second. Surely this is a statistics function? Isn&#039;t it that aPb and aCb thing, isn&#039;t it? The number you&#039;re after is the total number of UNIQUE combinations of two teams (if you care about home/away), or the total number of combinations (no duplicates), if you don&#039;t care about home/away.<BR><BR>Craig.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•