commit 850defccb747bbb04ffbbee94e4646a7ddb28505 Author: Colin Beveridge Date: Wed Jun 24 08:16:40 2026 +0000 Thue-Morse plotter Draw a pretty pattern based on the Thue-Morse sequence. diff --git a/plot.py b/plot.py new file mode 100644 index 0000000..24c2eb0 --- /dev/null +++ b/plot.py @@ -0,0 +1,32 @@ +import turtle + +SIZE = 5 +ANGLE = 108 +X0 = 0 +Y0 = 400 +DOUBLES = 14 # 14 takes "many minutes" on my machine. Each extra double doubles space and time required. +thue = "ABBA" +turtle.penup() +turtle.speed(0) +turtle.setx(X0) +turtle.sety(Y0) + +def extend(thue): + opp = "" + for i in thue: + if i == "A": + opp += "B" + else: + opp += "A" + return thue + opp + +for i in range(14): + thue = extend(thue) + +turtle.pendown() +for t in thue: + if t == "A": + turtle.forward(SIZE) + else: + turtle.forward(SIZE*2) + turtle.right(ANGLE)