Puzzle time - non repeating string
-
Is there a finite string of letters from the Latin alphabet with the property that there is no pair of adjacent identical substrings, but the addition of any letter to either end would create one?
(Examples: In the string ABCBCA there is a pair of adjacent identical substrings, namely BC followed immediately by another BC. But the string ABCACB has no such pair.)
-
Here's an example that works for a 3 letter alphabet.
click to showHere's one for 4 letters:
click to showI think I understood the construction principle now. I refrain from executing it for 26 letters since the string would have 2^26 - 1 characters.
-
Ah, got it now for the general case.
click to showBy the way, there is a well-known programming technique called hash consing with which such data which grows in size exponentially can still be represented in memory with linear space.