2

I am trying to generate the schedule for the league that has N players where N%2=0

Let's say for example I want to generate the schedule for 6 players (A, B, C, D, E, F) making distinct pairs.

Consider AB != BA and should be tracked as distinct pairs

Having 6 players there should be 30 different pairs. The number of pair combinations is pairsCount / (N / 2)

None of the following contest's pairs can be the same, e.g. if contest 1 had pair AB, contest 2 shouldn't have AB.

(AB) (CD) (EF)
(AC) (BE) (CF)

...

(BA) (DC) (FE)

...

I tried following this solution

Algorithm to generate all permutations of pairs without repetition

The problem is that following contest's pairs are the same as previous contest. I hope you will understand my problem and show me a good example on generating this kind of schedule.

  • I lost you there. So you've generated 30 different pairs, Then, you generate another 30 different pairs, and realize they are the same as the previous generation? Isn't this expected result as your 1st generation already has all possible pair permutations? Or did I understand your condition wrongly? – tctham Apr 16 '20 at 10:20
  • I think you understood it wrong. I'm generating 30 pairs just once. But using the solution I attached I get the wrong sequence: (AB) pair is found three time consequently. I don't want that. I don't want that player A would play against player B three weeks in a row. I want to mix this somehow, that each week they would play against different players. – Mantas Naidzinavičius Apr 16 '20 at 10:27
  • So you're getting the right `pairs`, but now you're trying to get them ordered correctly? Where two players should not meet in two consecutive weeks? – shapiro yaacov Apr 16 '20 at 11:37
  • That's correct. I think I found one solution here https://stackoverflow.com/questions/56730923/is-there-any-algorithm-to-make-round-robin-schedule-having-each-round-unique-com so far so good – Mantas Naidzinavičius Apr 16 '20 at 11:50
  • Is `BA` the same as `AB`? I think generally with problems like this, order doesn't matter within a specific group. Otherwise you are counting the same combination multiple times. There should only be 15 total results. If this is correct, then this is a known problem. It is called partitions of groups of equal size. I authored a package in `R` that attacks problems like this using the function `comboGroups(v = c("A", "B", .. "F"), numGroups = 3)`. See https://stackoverflow.com/a/57861934/4408538 – Joseph Wood Apr 17 '20 at 10:26

0 Answers0