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?