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


PROC Next(CHAR ARRAY s)
  BYTE i,len
  CHAR c
 
  IF s(0)=0 THEN
    s(0)=1 s(1)='0
    RETURN
  FI
 
  FOR i=1 TO s(0)
  DO
    IF s(i)='0 THEN
      c='1
    ELSE
      c='0
    FI
    s(s(0)+i)=c
  OD
  s(0)==*2
RETURN
 
PROC Main()
  BYTE i
  CHAR ARRAY s(256)
 
  s(0)=0
  FOR i=0 TO 7
  DO
    Next(s)
    PrintF("T%B=%S%E%E",i,s)
  OD
RETURN