OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..150
John Tyler Rascoe, Python code.
EXAMPLE
All prefixes of the word [1, 3, 2, 4, 1, 5, 3] satisfy the required conditions so this word is counted under a(7) = 867.
a(3) = 8: [1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 1], [1, 2, 3], [1, 2, 4], [1, 3, 1], [1, 3, 2].
MAPLE
b:= proc(n, l) option remember; `if`(n=0, 1, `if`(min(l[1], l[3])>0,
b(n-1, map(x-> x-1, l)), 0)+add((h-> `if`(h[1]>h[2] or h[2]>h[4]
or h[3]>h[4], 0, b(n-1, h)))(subsop(j=l[j]+1, l)), j=1..4))
end:
a:= n-> b(n, [0$4]):
seq(a(n), n=0..27); # Alois P. Heinz, Jan 10 2026
MATHEMATICA
b[n_, l_] := b[n, l] = If[n == 0, 1, If[Min[l[[1]], l[[3]]] > 0, b[n-1, l-1], 0] + Sum[Function[h, If[h[[1]] > h[[2]] || h[[2]] > h[[4]] || h[[3]] > h[[4]], 0, b[n-1, h]]][ReplacePart[l, j -> l[[j]]+1]], {j, 1, 4}]];
a[n_] := b[n, {0, 0, 0, 0}];
Table[a[n], {n, 0, 27}] (* Jean-François Alcover, Apr 09 2026, after Alois P. Heinz *)
PROG
(Python) # see links
CROSSREFS
KEYWORD
nonn
AUTHOR
John Tyler Rascoe, Jan 05 2026
EXTENSIONS
a(15)-a(27) from Alois P. Heinz, Jan 10 2026
STATUS
approved
