Talk:The Haruhi Problem/@comment-37308828-20181026142226

Hi Everyone! I wasn’t aware of the Haruhi problem up to these days, when someone on 4chan gave a kind of solution.

I had a look on it and I’d like to post here my approach.

The shortest string containing all the permutations of n digits occurs when you are able to take advantage of the maximum overlap between each permutation, obviously.

Given a permutation of n digits, I can find at maximum (n – 1) different permutations that grant the maximum overlap (n – 1) with an overall length of (2n – 1) digits.

Than I have to lower down to an overlap of (n – 2) for finding a new different permutation that grants other (n – 1) different ones with maximum overlap (n – 1); this new series has length equal to 2n – 1 – (n – 2) (I’m subtracting n – 2 because of the overlap with the previous permutation series).

Lets call L a string of n permutations with overlap (n – 1) between them.

I can put in a row (n – 1) L strings with overlap between them equal to (n – 2) than I have to lower down to (n – 3) for being able to create a new block.

Here it follows the L string lengths for n = 5:

L1 => length 9 (2n – 1)

L2 => length 6 (2n – 1 – (n – 2) for the overlap with L1)

L3 => length 6

L4 => length 6

_______________________________________

L5 => length 7 (2n – 1 – (n – 3) for the overlap with L4)

L6 => length 6

L7 => length 6

L8 => length 6

_______________________________________

L9 => length 7 (2n – 1 – (n – 3) for the overlap with L8)

L10 => length 6

L11 => length 6

L12 => length 6

_______________________________________

L13 => length 7 (2n – 1 – (n – 3) for the overlap with L12)

L14 => length 6

L15 => length 6

L16 => length 6

_______________________________________

L17 => length 7 (2n – 1 – (n – 3) for the overlap with L16)

L18 => length 6

L19 => length 6

L20 => length 6

_______________________________________

L21 => length 7 (2n – 1 – (n – 3) for the overlap with L20)

L22 => length 6

L23 => length 6

L24 => length 6

Total = 152

Lower bound formula = n^2(n – 2)! + n – 3

Hope my post could be of interest.

Best regards.