0
$\begingroup$

Given a list of people:

[
  1,
  2,
  3,
  4,
  5,
  6
]

The goal is to generate some number of lists of pairs.

[
  [
    [1,2],
    [3,4],
    [5,6]
  ],
  [
    [2,3],
    [4,5],
    [6,1]
  ],
  [
    [3,1],
    [5,2],
    [4,6]
  ],
  [
    [2,6],
    [3,5],
    [4,1]
  ],
  [
    [4,2],
    [5,1],
    [3,6]
  ]
]

Each list of pairs represents the schedule for that week. Each pair represents the people who should meet with that week.

In the example above, in the first week, persons 1 & 2, 3 & 4, 5 & 6 will meet. In the second week, persons 2 & 3, 4 & 5, 6 & 1 will meet and so on until everyone has meet with each other.

After some experimenting, it appears that for a list of n people, if n is even, there will be n - 1 lists of pairs. If n is odd, there will be n lists of pairs and one person will have a bye week where they don't meet with anyone.

Is there an algorithm to generate this list of pairs given a list of people?

$\endgroup$

1 Answer 1

1
$\begingroup$

When $n$ is odd, seat the $n$ players around a table, with one at the head and the others sitting across from each other in pairs. The pairs work together the first week. Everyone rotates one spot to the right each week.

Week 1

   2  3  4  5
1                 [2,9], [3,8], [4,7], [5,6] 
   9  8  7  6

Week 2

   1  2  3  4  
9                 [1,8], [2,7], [3,6], [4,5]
   8  7  6  5

Week 3

   9  1  2  3    
8                 [9,7], [1,6], [2,5], [3,4]
   7  6  5  4


etc.

When $n$ is even, you sit the people in pairs, and all but one of the people rotate each week. Below, person $1$ stays fixed.

Week 1

1  2  3  4
               [1,8], [2,7], [3,6], [4,5]
8  7  6  5

Week 2

1  8  2  3
               [1,7], [8,6], [2,5], [3,4]
7  6  5  4

Week 3

1  7  8  2
               [1,6], [7,5], [8,4], [2,3]
6  5  4  3

etc.
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .