Thue-Morse Sequence

 投稿者:しばっち  投稿日:2015年10月28日(水)22時19分23秒
  http://mathworld.wolfram.com/MephistoWaltzSequence.html

!'Thue-Morse Sequence
LET A$="01"
FOR N=1 TO 6
   LET B$=""
   FOR I=1 TO LEN(A$)
      SELECT CASE A$(I:I)
      CASE "0"
         LET B$=B$&"01"
      CASE "1"
         LET B$=B$&"10"
      END SELECT
   NEXT I
   LET A$=B$
NEXT N

!'Mephisto Waltz Sequence
!'LET A$="0"
!'FOR N=1 TO 5
!'   LET B$=""
!'   FOR I=1 TO LEN(A$)
!'      SELECT CASE A$(I:I)
!'      CASE "0"
!'         LET B$=B$&"001"
!'      CASE "1"
!'         LET B$=B$&"110"
!'      END SELECT
!'   NEXT I
!'   LET A$=B$
!'NEXT N
LET L=LEN(A$)
DIM M(L,L)
FOR X=1 TO L
   FOR Y=1 TO L
      LET M(X,Y)=MOD(VAL(A$(X:X))+VAL(A$(Y:Y)),2)
   NEXT Y
NEXT X
SET WINDOW 0,1,1,0
MAT PLOT CELLS, IN 0 , 0 ; 1 , 1 : M
END
 

戻る