OFFSET
0,3
LINKS
Wikipedia, Permutation
MAPLE
b:= proc(s, x, y) option remember; `if`(s={}, 1, add(
`if`(x=0 or y=0 or abs(abs(x-y)-abs(y-j))<=1,
b(s minus {j}, y, j), 0), j=s))
end:
a:= n-> b({$1..n}, 0$2):
seq(a(n), n=0..15);
MATHEMATICA
b[s_, x_, y_] := b[s, x, y] = If[s == {}, 1, Sum[
If[x == 0 || y == 0 || Abs[Abs[x - y] - Abs[y - j]] <= 1,
b[s ~Complement~ {j}, y, j], 0], {j, s}]];
a[n_] := b[Range[n], 0, 0];
a /@ Range[0, 15] (* Jean-François Alcover, Apr 26 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Alois P. Heinz, Nov 07 2020
STATUS
approved