A192296 Number of ternary words of length 2n obtained by self-shuffling.
1, 3, 15, 93, 621, 4425, 32703, 248901, 1934007, 15285771, 122437215, 991731999, 8107830597
Offset: 0
Examples
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.
Links
- N. Rampersad and J. Shallit, Shuffling and unshuffling, preprint, arXiv:1106.5767 [cs.FL], 2011.
Crossrefs
Cf. A191755.
Programs
-
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
Extensions
a(8)-a(9) from Alois P. Heinz, Sep 26 2011
a(10)-a(12) from Bert Dobbelaere, Oct 02 2018
Comments