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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login