# How to generalize the Thue-Morse sequence to more than two symbols?

The Thue-Morse sequence is defined as a binary sequence and can be generated like

0, 01, 01 10, 01 10 10 01, 01 10 10 01 10 01 01 10, ... .

So the second half of the series is always the binary complement of the first half of the series.

But is there a way to generate an analogous ternary sequence? Intuitively my first guess for a ternary Thue-Morse sequence was like

0, 01, 012, 012 120, 012 120 120 201, 012 120 120 201 120 201 201 012, ...

So here the second half of the series is the "ternary complement" (rotation 0->1, 1->2, 2->0 instead of 0->1, 1->0) of the first half.

But it could also be

0, 01, 012, 012 120 201, 012 120 201 120 201 012 201 012 120, ...

Here the second third is the "ternary complement" of the first third and the third third is the "ternary complement" of the second third.

Does any of my constructions for a ternary Thue-Morse series make sense? Is there maybe a unique way to generate an analogous ternary sequence? And how to construct n-ary versions of the Thue-Morse series in general?

-

It's $0, 012, 012 120 201, 012 120 201 120 201 012 201 012 120, ...$
To easily construct the Thue-Morse sequence, you can do the following: Start with 0 Replace $(0\to01)$ and $(1\to10)$. So you get: $$0, 0 1, 01 10, 0110 1001, 01101001 10010110,...$$
To easily construct the ternary version of Thue-Morse sequence, you can do the following: Start with 0 Replace $(0\to012), (1\to120), (2\to201).$ So you get: $$0, 0 1 2, 012 120 201, 012120201 120201012 201012120$$
To easily construct the $4$-ary version of Thue-Morse sequence, you can do the following: Start with 0 Replace $(0\to 0123), (1\to 1230), (2\to2301), (3\to3012).$ So you get: $$0, 0 1 2 3, 0123 1230 2301 3012, 0123123023013012 1230230130120123 2301301201231230 3012012312302301$$
To easily construct the $n$-ary version of Thue-Morse sequence, you can do the following: Start with $0$ Replace $$(0\to012\dots[n-2][n-1]n), (1\to123\dots[n-1]n0), (2\to234...n01),\dots(n\to n01\dots[n-3][n-2][n-1]).$$