OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..25
FORMULA
a(n) = A331562(n,n).
EXAMPLE
a(0) = 1: the empty sequence.
a(1) = 1: 1.
a(2) = 6: 1122, 1212, 1221, 2112, 2121, 2211.
a(3) = 92: 111222333, 111223233, 111223323, 111223332, ..., 333221112, 333221121, 333221211, 333222111.
MAPLE
b:= proc(l, q) option remember; (n-> `if`(n<2, 1, add(
`if`(l[j]=1, `if`(j in [1, n], b(subsop(j=[][], l),
`if`(j=1, 0, n)), 0), b(subsop(j=l[j]-1, l), j)), j=
`if`(q<0, 1..n, max(1, q-1)..min(n, q+1)))))(nops(l))
end:
a:= n-> b([n$n], -1):
seq(a(n), n=0..6);
MATHEMATICA
b[l_, q_] := b[l, q] = With[{n = Length[l]}, If[n < 2, 1, Sum[
If[l[[j]] == 1, If[j == 1 || j == n, b[ReplacePart[l, j -> Nothing],
If[j == 1, 0, n]], 0], b[ReplacePart[l, j -> l[[j]] - 1], j]], {j,
If[q < 0, Range[n], Range[Max[1, q - 1], Min[n, q + 1]]]}]]];
a[n_] := b[Table[n, {n}], -1];
Table[Print[n, " ", a[n]]; a[n], {n, 0, 8}] (* Jean-François Alcover, Jan 04 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Jan 22 2020
EXTENSIONS
STATUS
approved