Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

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

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
mSchmidt
Asked:
mSchmidt
1 Solution
 
ozoCommented:
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
 
rsripracCommented:
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
 
StimphyCommented:
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mSchmidtAuthor Commented:
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
 
ozoCommented:
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
 
mSchmidtAuthor Commented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now