Everyone is passed everything exactly once, but never from the same person

combinatorial-designscombinatoricsgraph theorypermutations

Say 4 or more people are sitting around a table. Each has a sheet of paper. Devise an algorithm to pass these papers between these people that guarantees:

  1. Each person passes and signs every piece of paper exactly once, no more, no less
  2. Every time the papers are passed, each person receives a paper from a person they have not received it from before
  3. The papers must all be passed the exact same number of times as there are people (i think this follows from 1, just making sure)
  4. People can only have one paper at a time; in other words, no person can be signing two papers at the same time.

Questions:

  1. Is there a mathematical name for this problem? Or can anyone find internet pages where this problem has been discussed before?
  2. Is this possible for every number of players?
  3. If so, is there an algorithm to generate this?
  4. If not, is there an algorithm that can at least minimize the number of times people receive a paper from someone they have received it from before?

This has real world implications!!! I would like to use this theoretical algorithm in my game Drawphone, more info here about how it fits in. Thanks! 🙂

Best Answer

W1hat you are looking for is equivalent to a row-complete Latin square. A Latin square is an $n\times n$ table filled with the numbers $1$ to $n$ so that each row and column has no repeats. A Latin square is further called row-complete if the $n\times (n-1)$ ordered pairs of numbers which occur horizontally adjacently in the square are also all distinct.

To apply this to your problem, given a row-complete Latin square, numbered the papers from $1$ to $n$. The rows represent people, the columns represent time, and the label at any row and column represents the paper that that person signs at the time. The Latin square conditions imply everyone has a different paper, and that everyone signs all papers. The row-complete condition ensures everyone receives their papers from a different person each time.

  • It is easy to solve the problem when $n$ is even. First, everyone passes their paper one spot to the left, then two spots to the right, then three spots to the left, then four spots to the right, and so on, ending with passing $(n-1)$ spots to the left.

  • It is proven in [Higgam] that when $n$ is odd and composite, a row complete Latin square of order $n$ exists. The construction uses finite fields. The construction is provided in that paper, and is also available in this survey by Otis, available online at https://www.combinatorics.org/ojs/index.php/eljc/article/view/DS10, in section 3.6.

  • All that remains are odd primes. No row-complete Latin square has been found for any odd prime order. Furthermore, exhaustive searches have shown there are no squares of orders $3,5$ and $7$. It is an open problem for higher odd primes.

In the odd prime case, where no row-complete Latin square is known to exist, the following method ensures that there is at most one repeat among the people who pass you the papers. Let $n=2m+1$. The algorithm differs slightly when $m$ is even vs odd.

  • In either case, the first $m$ steps are the same: start with passing one left, two right, three left, four right, and so on, ending at passing $m$ in a direction depending on the parity of $m$.

  • Next, if $m$ is odd...

    • Pass one spot to the left (this is the repeated pass). Then, pass $(m-1)$ spots left, $(m-2)$ right, $(m-3)$ left, $(m-4)$ right, and so on, down to passing one spot right.
  • If instead $m$ is even...

    • Start pass one spot to the right. Then, pass $(m-1)$ spots right, $(m-2)$ spots left, $(m-3)$ right, $(m-4)$ left, and so on down to $1$ spot right (this is the repeated step).

Examples

Approximate solution for $n=7$: (note the each explanation is for each column despite being written next to the row).

1 2 7 3 4 6 5   The first column is the initial paper distribution.
2 3 1 4 5 7 6   The second column is attained from the first by shifting up one.
3 4 2 5 6 1 7   The third is attained by the second by shifting down two.
4 5 3 6 7 2 1   The fourth from the third by shifting up three.
5 6 4 7 1 3 2   Next, you shift up one (again).
6 7 5 1 2 4 3   Then, shift up two.
7 1 6 2 3 5 4   Finally, shift down one.

Approximate solution for $n=9$:

1 2 9 3 8 7 4 6 5    
2 3 1 4 9 8 5 7 6    up one
3 4 2 5 1 9 6 8 7    down two
4 5 3 6 2 1 7 9 8    up three
5 6 4 7 3 2 8 1 9    down four
6 7 5 8 4 3 9 2 1    down one
7 8 6 9 5 4 1 3 2    down three
8 9 7 1 6 5 2 4 3    up two 
9 1 8 2 7 6 3 5 4    down one

Exact solution for $n=9$:

1 4 7 2 6 8 5 9 3
4 2 1 8 7 3 9 5 6   For the explanation, you will have to read the cited sources.
7 8 6 5 2 4 3 1 9
2 5 8 3 4 9 6 7 1
5 3 2 9 8 1 7 6 4
8 9 4 6 3 5 1 2 7
3 6 9 1 5 7 4 8 2
6 1 3 7 9 2 8 4 5
9 7 5 4 1 6 2 3 8

Higham, J. (1998), Row‐complete latin squares of every composite order exist. J. Combin. Designs, 6: 63-77. https://doi.org/10.1002/(SICI)1520-6610(1998)6:1<63::AID-JCD5>3.0.CO;2-U

Related Question