Task

Create a Thue-Morse sequence.



See also
   YouTube entry: The Fairest Sharing Sequence Ever
   YouTube entry: Math and OCD - My story with the Thue-Morse sequence
   Task: Fairshare between two and more


string 0;               \use zero-terminated strings
char Thue;
int  N, I, J;
[Thue:= Reserve(Free);  \reserve all available memory
Thue(0):= ^0;
J:= 1;                  \set index to terminator
for N:= 0 to 6 do
        [Thue(J):= 0;   \terminate string
        Text(0, Thue);  \show result
        CrLf(0);
        I:= 0;          \invert string and store it on the end
        repeat  Thue(J+I):= Thue(I) xor 1;
                I:= I+1;
        until   I = J;
        J:= J+I;        \set index to terminator
        ];
]