Solved

Have 4-10 teams need to create game rounds, where each team gets to play against each other from 1-3 times

Posted on 2004-08-30
6
228 Views
Last Modified: 2010-04-17
Hi
I have a program where the user may choose from 4-10 teams and then choose how many times these are to play against each other (1 - 3 times)

So the first round could be
Team 1 vs Team 2
Team 3 vs Team 4
Team 5 vs Team 6

now the thing is that the algorithm i want should make sure that all teams play against each other the chosen times and that each team should have equally many Home and Away games, left and right in my example... Does someone have a fast example of how this can be accomplished ?
0
Comment
Question by:mSchmidt
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 11936587
6 1
5 2
4 3

6 2
1 3
5 4

6 3
2 4
1 5

6 4
3 5
2 1

6 5
4 1
3 2

I hope you see the pattern
0
 
LVL 5

Accepted Solution

by:
rsriprac earned 500 total points
ID: 11937555
A way to visualize it is this (I'm not sure if I'm getting the questiong correctly tho):

If you have X teams to play each other Y times, this is called a "complete graph" (http://mathworld.wolfram.com/CompleteGraph.html).  Where the X is the number of dots on the graph, and the Y is how many times you repeat the drawing the graph.

Lets number the dots 1 ... X.  So to form this graph, we pick a starting dot, lets pick 1.  1 will play all the other team first (exclude it self), i.e. (1,2), (1,3), (1,4), ... (1,X).  Now its 2's turn, since they already played team 1, then we start with (2,3), then (2,4), (2,5), ... (2,X).  Now its 3's turn, and since they played team 1 and 2, then they play: (3,4), (3,5), ... (3,X).

This will make sure that all teams play each other.  If Y >1, then you just re-run the about Y times.

-Ram
0
 
LVL 3

Expert Comment

by:Stimphy
ID: 11938502
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mSchmidt
ID: 11939498
The complete graph does not take into account the amount of home and away games which the teams will play,

Which is a very important issue in this calculations, as i see it the latin Squares do not take this into consideration either...
0
 
LVL 84

Expert Comment

by:ozo
ID: 11939722
When there are an even number of teams and an odd number of times play against each other, each team will play an odd number of games, so they can't have equally many Home and Away games.
With an even number of times to play against each other, they can just play half the games with one team at home and the other half with the other team at home.
0
 

Author Comment

by:mSchmidt
ID: 11940005
With an even number of teams and an odd number of round each team will as you say play an odd number of games but this does not mean that T1 in the last round should play all its games on the Home (left side), even though this would result in T2, T3 and T4 only having played one game additionally on the Away lane, it resulted in T1 playing 3 games on the Home lane.

Going back to my first question i would like an example of how this could be coded ( in for instance VB 6)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question