Plain Hunt Bell-Ringing Your task is to create a plain hunt (a bell ringing pattern) with n bells. An example with 6 bells:

123456
214365
241635
426153
462513
645231
654321
563412
536142
351624
315264
132546
123456


Each number "bounces" off the side of the grid. From Wikipedia:


  Each bell moves one position at each succeeding change, unless they reach the first or last position, when they remain there for two changes then proceed to the other end of the sequence.


In other words, you swap the bells in adjacent pairs, alternating between taking pairs starting from the the first bell and from the second bell. (Thanks to @xnor for this explanation.) You finish in the same order as the start.

This rule be applied to any number of bells, taken as input.
Standard loopholes are forbidden.

Test Cases

6

123456
214365
241635
426153
462513
645231
654321
563412
536142
351624
315264
132546
123456


3

123
213
231
321
312
132
123


2

12
21
21
12


1

1


0: Falls in to "I don't care" situation.
Python 2, 93 bytes



lambda n:[[.5+abs((n+j-i*(-1)**(i+j))%(2*n)-n+.5)for j in range(n)]for i in range(2*n+(n&gt;2))]


Try it online!

Outputs a list of lists of integer-valued floats.

The map (i,j) -&gt; j-i*(-1)**(i+j) is very similar to multiplication in the dihedral group. This isn't a coincidence. If we let \$a\$ represent swapping every other element starting from the first, and \$b\$ doing so starting from the second, then these generate the dihedral group \$D_{2n}\$ gives by relations \$a^2 = b^2 =(ab)^n =1 \$. Note that the sequence we're asked to output has us alternate applying \$a\$ and \$b\$, and the fact that \$ (ab)^n =1 \$ confirms that we return to where we started after \$2n\$ total steps.

We can see the dihedral connection more clearly if we extend the top row to \$2n\$ elements rather than \$n\$, and write it zero-indexed. Doing the alternating swaps as usual gives a pattern like below for \$n=3\$. This is almost a multiplication table for the dihedral group \$D_{2n}\$, except that we invert the first group element before multiplying \$g,h \to g^{-1} h \$, giving zeroes (identity) on the diagonal \$g=h\$.

  012345
 +------
0|012345
1|103254
2|430521
3|345012
4|254103
5|521430


To return the values back into the range [0,1,2], we need to map back 3-&gt;2, 4-&gt;1, 5-&gt;0. In the code, surprisingly many characters as spent on the simple-looking mapping doing modular indexing into the palindromic "bouncing" list [1,2,...,n-1,n,n,n-1,...,2,1], We implement this as .5+abs((n+k)%(2*n)-n+.5). The Python 3.8 walrus can save at least 2 bytes, though I haven't optimized it.