Function Repository Resource:

OverlapFreeStringTuples

Source Notebook

Find all overlap-free strings of a specified length

Contributed by: Stephen Wolfram

ResourceFunction["OverlapFreeStringTuples"][n]

gives strings composed of two characters with lengths up to n that do not self overlap.

ResourceFunction["OverlapFreeStringTuples"][k,n]

gives strings composed of k characters with lengths up to n that do not self overlap.

ResourceFunction["OverlapFreeStringTuples"][k,n,s]

gives s-tuples of strings of k characters with lengths up to n that do not overlap themselves or each other.

Details and Options

ResourceFunction["OverlapFreeStringTuples"] makes strings out of alphabetic characters from A to Z.

Examples

Basic Examples (5) 

Find overlap-free strings with lengths up to 5:

In[1]:=
ResourceFunction["OverlapFreeStringTuples"][5]
Out[1]=

Find overlap-free strings with lengths up to 4 and a 3-letter alphabet:

In[2]:=
ResourceFunction["OverlapFreeStringTuples"][3, 4]
Out[2]=

Find overlap-free pairs of strings with 2-letter alphabets and lengths up to 5:

In[3]:=
ResourceFunction["OverlapFreeStringTuples"][2, 5, 2]
Out[3]=

There are no triples of non-overlapping strings up to length 5:

In[4]:=
ResourceFunction["OverlapFreeStringTuples"][2, 5, 3]
Out[4]=

At length 6, there are overlap-free triples of strings:

In[5]:=
ResourceFunction["OverlapFreeStringTuples"][2, 6, 3]
Out[5]=

Version History

  • 1.0.0 – 19 December 2019

Related Resources

Author Notes

It may make sense to cache some common results.

License Information