Output a Sturmian sequence
+2
−0
A Sturmian sequence is an infinite binary sequence satisfying two properties:
- It is balanced. This can be stated a number of equivalent ways:
- There is no pair of equal length subwords whose digit sums differ by 2 or more.
- There is no string $w$ such that $0w0$ and $1w1$ are both substrings.
- It is not eventually periodic. No (infinite) suffix of the sequence consists of a finite string repeated infinitely.
Your challenge is to output a Sturmian sequence of your own choosing.
You may output an infinite sequence in any of the following ways:
- Output an infinite list or some sort of lazy sequence structure.
- Print the terms of the sequence in order indefinitely.
- Take an input $n$ and output the $n$th term of your sequence. ($1$ indexing is permitted)
- Take an input $n$ and output the first $n$ terms of your sequence.
This is code-golf, so the goal is to minimize the size of your source code as measured in bytes.

0 comment threads