triplets of people who never met before

31 Views Asked by At

let's say we have n people and m tables with three seats for each table. n is divisible by m.

People took places randomly. Our goal is to re-sit them in such a way that none of those who met before will not sit with the same person again.

Is there a way to get all possible combinations like that?

an example:

If we enumerate people, they initially sit like that (each sublist is a separate table): [[1, 2, 3], [4, 5, 6,], [7,8,9]]

at the next iteration we shuffle them so that none of them will meet again: [[1, 4, 7], [2, 5, 8,], [3, 6, 9]]

at the next iteration it can be: [[1, 5, 9], [2, 6, 7,], [4, 8, 3]]

at the next iteration it can be: [[7, 5, 3], [4, 2, 9,], [1, 8, 6]]

Is this list exhaustive or are there any other combinations that satisfy the condition?

I don't need a full 'solution' but maybe just a hint where to dig to.