TITLE: Generating seating plans- maximal number of orderings with different adjacencies
QUESTION [5 upvotes]: Background:
So the school I work at has a policy that we try and sit the kids next to as many different other kids as possible throughout the academic year. This means rejigging the seating plan as often as you can be bothered to.
With a decentish understanding of VBA, I figured I'd write a macro to take care of this for me, but I've come up against a snag.
The basic algorithm is to shuffle the list, then transcribe that to a seating plan in a predefined way. The hope is to shuffle the list in such a way that no two students are adjacent that were before.
But my problem is there seems no simple way of characterising these shuffles.
Maths
So suppose we have an ordered list of n elements (possibly it will be easier to consider it as cyclic list, so that n is adjacent to 1), how can one reliably generate the maximum number of reorderings of that list in which no two reorderings share adjacent pairs?
One obvious strategy might be a random walk on $S_n$, but without knowing the maximal number this could go on forever looking for a reordering that wasn't there. So a natural supplementary question is: what is the maximal number of such reorderings?
Failing that, what is a reliable way of making (a possibly suboptimal number of) 'mixing' reorderings?
So far I have experimented with Faro shuffles (which do not guarantee mixing under composition), groups of invertible elements in $\mathbb{Z}_n^\times$ (multiplicative group of integers modulo n- which seem quite meagre in only offering $ \phi(n)$/2 reorderings), and have toyed with some random-walk code, all to no avail.
I'm sure this is all just a reflection of my ignorance of combinatorics- that the answer will turn out to be a fraction with a couple of factorials, or that it's a famous problem or some such. But I'm stumped.
Any help you could give would be ace. Thanks!

REPLY [2 votes]: I assume that your school doesn't have King Arthur's Round Table, so they aren't really in one long chain.
Are they just in pairs?  If you have $N$ tables, each sits 2 students, you can do this:
(1) Student 1 sits in the left-hand side of Table 1 forever.
Each time you move students,
   (a) everyone on the left-hand side moves up one table,
   (b) everyone on the right-hand side moves down one table
   (c) The left-hand student on Table $N$ moves to the right-hand side of Table $N$
   (d) The right-hand student on Table 1 moves to the left-hand side of Table 2.
You can disguise it obviously by going to the $m^{th}$ position instead of the next position.  It has the disadvantage that the people in front and behind you stay the same.
If you put the tables in some order (not Table $k$ in front of Table $k+1$, you might be able to make the people in front and behind you change regularly.  I am not sure how to do that.  If $N+1$ is prime, you might find a generator $g$ of $\mathbb{Z}_{N+1}^{\times}$
and order the tables according to the powers of $g$.
That just leaves the people in the next aisle; I think that depends on how many aisles.