I'm trying to figure out what algorithm / method I can use to figure out how to pair people together such that the pairs aren't repeated

i.e. if a unique individual is denoted by Px where x is their "number"

Day 1 : P1-P2; P3-P4; P5-P6;
Day 2 : P1-P3; P2-P5; P4-P6;
Day 3 : P1-P4; P3-P6; P3-P5;

I did the above manually and no pairs are repeated on subsequent days. I need to do this but for 40 people over 20 days.

Is there a quick method or algorithm I can use?


1 Answer 1


You basically have a tournament.

In a round-robin tournament, 40 players can play 39 rounds and meet each player exactly once.

The Wikipedia article on round robin tournaments has a description of a simple algorithm to generate the pairings for each round. There are also pre-computed tables on the Internet (look for Berger tables, for instance), but not normally for 40 players as that is quite a lot.

Then you just pick your favorite 20 rounds out of the 39.

Not the answer you're looking for? Browse other questions tagged or ask your own question.