# Does the principle of De Bruijn sequences extend to non-repeating combinations?

The basic principle of the De Bruijn sequence is that for an alphabet of $k$ letters all combinations of $n$-letter words can be found in a sequence of length $k^n$ letters. For example, given the possibility of any ATM pin containing 4 digits (0-9), there is a sequence of $10^4=10000$ digits which contains every possible pin. The length of the De Bruijn sequence is the same as the number of permutations of the letters.

The question is whether this principle extends to words in which the letters are not allowed to repeat. For example, mechanical door combinations do allow the code to repeat the same digit. Imagine a 5-digit mechanical door lock with buttons numbered 1,2,3,4,5. The code is 4-digits long and digits may not be repeated, so there are $5x4x3x2 = 120$ possible combinations.

Does that imply that there is a 120-digit De Bruijn sequence which contains all possible codes for the mechanical lock?

## 1 Answer

No.

Assume that such a sequence existed. Without loss of generality (relabel the digits) we can assume that the sequence begins with 12345... What could the next digit be? It cannot be any of 2,3,4,5 for then there would be a run of 5 digits such that this digits appears twice, which was explicitly forbidden. Therefore the sixth digit needs to be a 1. Repeating the argument we see that the seventh number must be a 2, the eight a 3, the ninth a 4, and the tenth a 5, at which point we have repeated the sequence 12345 way too soon.

• This sounds like a dup, walks like a dup and talks like dup... But I could not find one :-( – Jyrki Lahtonen Apr 28 '15 at 8:09
• That make sense except the last sentence. In a De Bruijn sequence you cannot ever repeat any word-length sequence, otherwise it would impossible to express all possible words use only n^k letters. – Tyler Durden Apr 28 '15 at 13:34
• @TylerDurden: Well, my goal was to arrive at the contradiction starting from the assumption that such a sequence would exist. The conclusion is that the sequence you are looking for does not exist. – Jyrki Lahtonen Apr 29 '15 at 6:59