%I #25 Apr 26 2021 08:53:52
%S 1,1,2,5,1,20,4,102,18,626,92,2,4458,564,18,36144,4032,144,328794,
%T 32898,1182,6,3316944,301248,10512,96,36755520,3057840,102240,1200,
%U 443828184,34073184,1085904,14304,24,5800823880,413484240,12538080,174000,600,81591320880
%N Number T(n,k) of permutations of [n] having exactly k consecutive triples j, j+1, j-1; triangle T(n,k), n>=0, 0<=k<=floor(n/3), read by rows.
%C Terms in column k are multiples of k!.
%H Anders Claesson, <a href="https://akc.is/papers/036-From-Hertzsprungs-problem-to-pattern-rewriting-systems.pdf">From Hertzsprung's problem to pattern-rewriting systems</a>, University of Iceland (2020).
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Permutation">Permutation</a>
%F T(3n,n) = n!.
%e T(4,1) = 4: 1342, 2314, 3421, 4231.
%e Triangle T(n,k) begins:
%e 1;
%e 1;
%e 2;
%e 5, 1;
%e 20, 4;
%e 102, 18;
%e 626, 92, 2;
%e 4458, 564, 18;
%e 36144, 4032, 144;
%e 328794, 32898, 1182, 6;
%e 3316944, 301248, 10512, 96;
%e 36755520, 3057840, 102240, 1200;
%e 443828184, 34073184, 1085904, 14304, 24;
%e 5800823880, 413484240, 12538080, 174000, 600;
%e 81591320880, 5428157760, 156587040, 2214720, 10800;
%e 1228888215960, 76651163160, 2105035440, 29777520, 175800, 120;
%e ...
%p b:= proc(s, l, t) option remember; `if`(s={}, 1, add((h->
%p expand(b(s minus {j}, j, `if`(h=1, 2, 1))*
%p `if`(t=2 and h=-2, x, 1)))(j-l), j=s))
%p end:
%p T:= n-> (p-> seq(coeff(p, x, i), i=0..degree(p)))(
%p b({$1..n}, -1, 1)):
%p seq(T(n), n=0..13);
%t b[s_, l_, t_] := b[s, l, t] = If[s == {}, 1, Sum[Function[h,
%t Expand[b[s ~Complement~ {j}, j, If[h == 1, 2, 1]]*
%t If[t == 2 && h == -2, x, 1]]][j - l], {j, s}]];
%t T[n_] := CoefficientList[b[Range[n], -1, 1], x];
%t T /@ Range[0, 13] // Flatten (* _Jean-François Alcover_, Apr 26 2021, after _Alois P. Heinz_ *)
%Y Column k=0 gives A212580.
%Y Row sums give A000142.
%Y Cf. A047921, A123513, A197365, A216716.
%K nonn,tabf
%O 0,3
%A _Alois P. Heinz_, Apr 18 2021