Arbitrary-length analogs to de Bruijn sequences
Let be a length- cyclic sequence of characters from a size- alphabet such that the number of occurrences of any length- string on as a substring of is or . When for any positive integer , is a de Bruijn sequence of order , and when , shares many properties with de Bruijn sequences. We describe an algorithm that outputs some for any combination of and in time using space. This algorithm extends Lempel's recursive construction of a binary de Bruijn sequence. An implementation written in Python is available at https://github.com/nelloreward/pkl.