0

I need to calculate a sequence of numbers (similar to Sudoku) to match teams to play each other.

I need to create a matrix for 8 and 9 teams and can't figure out the formula. I have to believe this is really simple, but I have no idea what to search for to find it.

Here is a working version for 7 teams:

team     |1 2 3 4 5 6 7
====================
week 1 |   7 6 5 4 3 2
week 2 | 7   5 6 3 4 1
week 3 | 6 5   7 2 1 4
week 4 | 5 6 7   1 2 3
week 5 | 4 3 2 1   7 6
week 6 | 3 4 1 2 7   5
week 7 | 2 1 4 3 6 5  

So for the first week, team 1 doesn't play (no available partner), team 2 plays team 7, team 3 plays team 6, etc. For week 2, team 1 plays team 7, etc.

No team may play the other team. The event continues for as many weeks as we have teams, so 8 teams would play for 8 weeks.

Each team should play another team once and only once. They can't play themselves (hence the blank entry in each row.

Note that the upper right triangle is a mirror of the bottom left triangle, but that still didn't help me determine the formula.

My guess is that if I spent enough hours, I could figure out the formula. But since this has to have been done a few million times by people over the ages, I am guessing that it's a well known algorithm and I just need to find someone who knows the name (so I can look it up) or can tell me what it is so I can create this for a friend who needs it.

Thanks!

JustMeToo
  • 325
  • 1
  • 14

1 Answers1

0

The best answer so far is from Dennis Meng (I can't comment, so I have to use an answer). That link pointed me to a question where the answer worked, sort of. I don't have an algorithym yet, but the methodology worked adequately. I have my rows and columns. It doesn't provide me with a "mirror" image the way the example does. But it does give me a unique team for each week. I am hoping that will be enough.

I just used excel to lay it out as that was faster than trying to figure out the logic, write the code, and get a nice formatted result - especially since I only seem to need to do it once.

But if it turns out I need to do it again, I will write a simple application and post it here.

Of course, it would be great if I could get the routine that generated the above matrix....

Of course, that also leads me to another issue. How can I mark Dennis' comment as the answer???? He deserves the credit (unless someone chimes in with the mirror solution....)

Oh well, thanks Dennis!

JustMeToo
  • 325
  • 1
  • 14
  • `"I can't comment"` - As far as I know, you can comment on your own posts and answers to your questions. **Although**, linking to another question is not an answer. The question should simply be marked as a duplicate and that should be the end of it. You can flag your question as a duplicate (by clicking the `flag` button below the question), which will bring it to the attention of higher reputation users, who can mark it as such it if they agree. – Bernhard Barker Sep 27 '13 at 17:45
  • I thought so too, but it wouldn't let me at the time... Now it does, weird. – JustMeToo Oct 03 '13 at 18:12
  • Also, the thread the Dennis pointed me to helped me figure it out, it wasn't really an answer - it just made it easier. I still don't have the mirror ability, but I think I can get by with what I do have. So there isn't a duplicate question issue. – JustMeToo Oct 03 '13 at 18:14