login
Number of length n words over the alphabet [5] such that any prefix satisfies c(1) >= c(2), c(1) >= c(3), c(2) >= c(4), c(3) >= c(5), and c(4) >= c(5), where c(i) is the number of occurrences of the letter i.
2

%I #23 Apr 09 2026 09:01:20

%S 1,1,3,8,23,73,246,867,3166,11839,45785,179579,717113,2908753,

%T 11954189,49750400,208980669,885742796,3787356399,16314829868,

%U 70763117954,308802296807,1355046242737,5978469864061,26504591207399,118019589079173,527734730588274,2368700497250917

%N Number of length n words over the alphabet [5] such that any prefix satisfies c(1) >= c(2), c(1) >= c(3), c(2) >= c(4), c(3) >= c(5), and c(4) >= c(5), where c(i) is the number of occurrences of the letter i.

%H Alois P. Heinz, <a href="/A392274/b392274.txt">Table of n, a(n) for n = 0..150</a>

%H John Tyler Rascoe, <a href="/A392274/a392274.py.txt">Python code</a>.

%e 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.

%e 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].

%p b:= proc(n, l) option remember; `if`(n=0, 1, `if`(min(l[1], l[3])>0,

%p b(n-1, map(x-> x-1, l)), 0)+add((h-> `if`(h[1]>h[2] or h[2]>h[4]

%p or h[3]>h[4], 0, b(n-1, h)))(subsop(j=l[j]+1, l)), j=1..4))

%p end:

%p a:= n-> b(n,[0$4]):

%p seq(a(n), n=0..27); # _Alois P. Heinz_, Jan 10 2026

%t 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}]];

%t a[n_] := b[n, {0, 0, 0, 0}];

%t Table[a[n], {n, 0, 27}] (* _Jean-François Alcover_, Apr 09 2026, after _Alois P. Heinz_ *)

%o (Python) # see links

%Y Cf. A000351, A006966, A384725, A391270.

%K nonn

%O 0,3

%A _John Tyler Rascoe_, Jan 05 2026

%E a(15)-a(27) from _Alois P. Heinz_, Jan 10 2026