login
A181047
Number of length-n sequences A over {1,2,3} with the property that all of r(A), r(r(A)), etc. are over {1,2,3}, where r is the sequence obtained by taking the run lengths in A.
0
1, 3, 9, 27, 54, 180, 426, 1080, 2724, 6300, 16512, 42432, 98064, 248256, 616656, 1509888, 3767040, 9389376, 23549376, 58493760, 140807232, 336314880, 806979456
OFFSET
0,2
EXAMPLE
For example, the run-lengths in 1333 are 13, then the run-lengths of this is 11, then the run-lengths of this is 2, then the run-lengths of this is 1, so this sequence is counted in a(4).
PROG
(Python)
from itertools import groupby, product
def r(w):
return [len(list(g)) for k, g in groupby(w)]
def c(w):
while (rw:=r(w)) != w:
if not set(rw) <= {1, 2, 3}: return False
w = rw
return True
def a(n):
if n == 0: return 1
return 3*sum(1 for w in product((1, 2, 3), repeat=n-1) if c((1, )+w))
print([a(n) for n in range(14)]) # Michael S. Branicky, Jan 06 2026
CROSSREFS
Sequence in context: A163791 A248078 A057829 * A014948 A093665 A093546
KEYWORD
nonn,hard,more
AUTHOR
Jeffrey Shallit, Oct 01 2010
EXTENSIONS
a(0)-a(10) confirmed and a(11)-a(14) added by John W. Layman, Oct 07 2010
a(15)-a(16) from Alois P. Heinz, Oct 16 2011
a(17)-a(22) from Michael S. Branicky, Jan 06 2026
STATUS
approved