PDA

View Full Version : math problem



nakulak
10-24-2005, 09:30 AM
I ran into a little math problem, if anyone has the solution it would be appreciated.

I was making a schedule for 3x TDM matches (3 teams play in one game).

the background:
prior to now, I only dealt with 6 teams, so the solution was to iterate the teams : set of teams T= {1,2,3,4,5,6}

total games C(m,n)=C(6,3)=20 games,
if the list ofgames is iterated as follows:
match1=123,
match2=124,
match3=125
.
.
.
match20=456
then it turns out to be a trivial case, because match1 is reflexive to match 20, so the schedule turns out to be
week1=match1,match20
week2=match2,match19
etc.

the problem:
well, when you have 9 teams {1,2,3,4,5,6,7,8,9},
C(m,n)=C(9,3)=84 matches

now, the problem is to have all nine teams play in groups of 3, where all 9 members are unique members of the set of teams T.

so, for example, one match would be
Weekx= Game 1{1,2,3},Game 2 {4,5,6}, Game 3{7,8,9}

but there is no obvious case for iterating the subsets so that I can compile a list of 28 weeks x 3 matches per week, where all the members are unique (the 9 teams each play 1 game that week)

now, its clear that with 84 games, the combinations are 84*83*82/3!= 95k combinations of the games, and its clear that I could program the schedule program to filter out the bad ones by using the total of the indexes (ie, if the sum of the indexes doesn't = 1+2+3...+9, then the set of 3 games giving those indexes has a repeating element and can be thrown out,and while intuitively it seems clear that there should be 28 groups of 3 sets of 3 elements that would make a schedule of all the 84 unique games, its not obvious how to iterate the items, nor is it clear as to how many solutions there are.

SOOO..., I was wondering if someone knew of an easier way to iterate the team#'s to that the answer was much easier, if not trivial.

anyway, if anyone does , please post or email me nakulak@comcast.net
(if you do, all I really need is the list of indexes using the #'s 1 thru 9 and I can use the indexes as pointers to the array of strings containing the team names to generate the schedule, or the method for iterating the indexes that provides a trivial solution)

thx

nakulak
10-24-2005, 10:38 PM
well, I did it brute force with some really crappy code, but my computer finally determined that there are 280 combinations of 9 numbers that have the 9 unique numbers in them, (like {123456789}

then I had the computer start at one end and add each one to a list when it found that none of the subsets of 3 {123456789}=>{123},{456},{789}
were contained in any of the ones saved to the list so far (ie no match up of any 3 teams is repeated)

unfortunately, the computer only came up with 25 answers lol. which means that to find the 28 matchups that form the whole set of 84 games of 3 players, the computer has to permutate the 280 sets, check them as above, and find the solution. it appears that there are over 10 to the 20th power combinations, so I guess it could be a while before I have the answer LOL