Improve company productivity with a Business Account.Sign Up

x
?
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
Medium Priority
?
238 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 85

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 2000 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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 

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 85

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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Article by: Shaun
Tiling windows is a great way to see multiple applications at once. Windows Tiler is a tool that automatically tiles open application windows as the open and close.
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 …
Introduction to Processes

586 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