A219762 Start with 0; repeatedly apply the map {0->012, 1->120, 2->201} to the odd-numbered terms and {0->210, 1->021, 2->102} to the even-numbered terms.
0, 1, 2, 0, 2, 1, 2, 0, 1, 2, 1, 0, 2, 0, 1, 0, 2, 1, 2, 0, 1, 2, 1, 0, 1, 2, 0, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 0, 1, 2, 1, 0, 1, 2, 0, 2, 1, 0, 2, 0, 1, 0, 2, 1, 2, 0, 1, 2, 1, 0, 1, 2, 0, 1, 0, 2, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 1, 0, 2, 1, 2, 0, 1, 0, 2, 0, 1, 2, 1, 0, 2, 1, 2, 0
Offset: 1
Keywords
Examples
0 -> 012 -> 012021201 -> ...
References
- A. Salomaa, Jewels of Formal Language Theory. Computer Science Press, Rockville, MD, 1981, p. 16, Problem 13.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
a219762 = subtract 1 . a099054 . subtract 1 -- Reinhard Zumkeller, Aug 08 2014
-
Mathematica
f[lst_] := Replace[MapIndexed[{#1, #2[[1]]}&, lst], {{0, n_} :> If[OddQ[n], {0, 1, 2}, {2, 1, 0}], {1, n_} :> If[OddQ[n], {1, 2, 0}, {0, 2, 1}], {2, n_} :> If[OddQ[n], {2, 0, 1}, {1, 0, 2}]}, 1] // Flatten; Nest[f, {0}, 5] (* Jean-François Alcover, Mar 07 2014 *)
Formula
a(n) = A099054(n-1) - 1. - Reinhard Zumkeller, Aug 08 2014
Comments