[go: up one dir, main page]

login
A192296
Number of ternary words of length 2n obtained by self-shuffling.
2
1, 3, 15, 93, 621, 4425, 32703, 248901, 1934007, 15285771, 122437215, 991731999, 8107830597
OFFSET
0,2
COMMENTS
See A191755 for the number of binary words of length 2n obtained by self-shuffling and also for an explanation of "self-shuffling" and a reference.
LINKS
N. Rampersad and J. Shallit, Shuffling and unshuffling, preprint, arXiv:1106.5767 [cs.FL], 2011.
EXAMPLE
a(2) = 15 because {0,0,0,0}, {0,0,1,1}, {0,0,2,2}, {0,1,0,1}, {0,2,0,2}, {1,0,1,0}, {1,1,0,0}, {1,1,1,1}, {1,1,2,2}, {1,2,1,2}, {2,0,2,0}, {2,1,2,1}, {2,2,0,0}, {2,2,1,1}, {2,2,2,2} (and no other ternary words of length 4) are generated by self-shuffling.
PROG
(Python)
from itertools import product, combinations
def a(n):
if n<=1: return 3**n
range2n, set2n = list(range(2*n)), set(range(2*n))
allset, ssw = set(), [0 for i in range(2*n)]
for w in product("012", repeat=n-1):
w = "0" + "".join(w)
if w.count("1") > w.count("2"): continue
for s in combinations(range2n, n):
nots = sorted(set2n-set(s))
for i, c in enumerate(w): ssw[s[i]] = ssw[nots[i]] = c
allset.add("".join(ssw))
num2g1 = sum(w.count("1") < w.count("2") for w in allset)
return 3*(len(allset) + num2g1)
print([a(n) for n in range(8)]) # Michael S. Branicky, Jan 03 2021
CROSSREFS
Cf. A191755.
Sequence in context: A361881 A303558 A193661 * A372374 A370218 A002893
KEYWORD
nonn,more
AUTHOR
John W. Layman, Jun 27 2011
EXTENSIONS
a(8)-a(9) from Alois P. Heinz, Sep 26 2011
a(10)-a(12) from Bert Dobbelaere, Oct 02 2018
STATUS
approved