Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

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.

History

0 comment threads

Sign up to answer this question »