All pairs of letters (de Bruijn sequence with $n=2,k=52$)
Suppose I’m designing a font and want to verify its kerning.
Ignoring punctuation, I want to generate a string made of $52$ symbols (uppercase A
to Z
and lowercase a
to z
), so that all possible letter pairs occur at least once.
I looked up similar problems, and it seems that what I want is a de Bruijn sequence. However, I couldn’t find anything online relating to an alphabet size $k>9$.
How long would my de Bruijn sequence be, and how would I go about generating said sequence?
Solution 1:
For $n=2$, such sequences are trivial to create. Begin with 'zA' and continually append the lowest value that completes a previously unseen pair:
zAABACAD...AxAyAzBBCBDBE...BxByBzCCDCECF....wwxwywzxxyxzyyzzA