OFFSET
0,4
COMMENTS
This is the (UDU)* version of 3-alternating permutations of [n], (U=Up, D=Down).
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..500
J. M. Luck, On the frequencies of patterns of rises and falls, arXiv:1309.7764, 2013
Anthony Mendes and Jeffrey Remmel, Generating functions from symmetric functions, Preliminary version of book, available from Jeffrey Remmel's home page
R. P. Stanley, A survey of alternating permutations, arXiv:0912.4240, 2009
EXAMPLE
a(2) = 1: 12.
a(3) = 2: 132, 231.
a(4) = 5: 1324, 1423, 2314, 2413, 3412.
a(5) = 9: 13245, 14235, 15234, 23145, 24135, 25134, 34125, 35124, 45123.
a(6) = 40: 132465, 132564, 142365, 142563, 143562, 152364, 152463, 153462, 162354, 162453, 163452, 231465, 231564, 241365, 241563, 243561, 251364, 251463, 253461, 261354, 261453, 263451, 341265, 341562, 342561, 351264, 351462, 352461, 361254, 361452, 362451, 451263, 451362, 452361, 461253, 461352, 462351, 561243, 561342, 562341.
a(7) = 169: 1324657, 1324756, 1325647, ..., 6723514, 6724513, 6734512.
MAPLE
b:= proc(u, o, t) option remember; `if`(u+o=0, 1,
`if`(t=2, add(b(u-j, o+j-1, irem(t+1, 3)), j=1..u),
add(b(u+j-1, o-j, irem(t+1, 3)), j=1..o)))
end:
a:= n-> b(0, n, 0):
seq(a(n), n=0..35);
MATHEMATICA
b[u_, o_, t_] := b[u, o, t] = If[u + o == 0, 1, If[t == 2, Sum[b[u - j, o + j - 1, Mod[t+1, 3]], {j, 1, u}], Sum[b[u + j - 1, o - j, Mod[t+1, 3]], {j, 1, o}]]];
a[n_] := b[0, n, 0];
Table[a[n], {n, 0, 35}] (* Jean-François Alcover, Nov 06 2017, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Nov 01 2014
STATUS
approved