What is the shortest string of numbers that contains all numbers from 0 to 1000

I am sitting at my desk and I just came up with a problem, and I was wondering if anyone could come up with a solution or a way to prove it mathematically.

Let's say I wanted to find the shortest string of numbers containing each number from 0 to 1000. For example, the string "1433" contains the numbers 1, 4, 3, 14, 43, 33, 143 and 433.

What algorithm can I use to build the shortest string containing all the numbers 0-1000.

I have no practical reason why I want to know, but I would be interested to hear if she is.

+3
source share
1 answer

de Bruijn. , de Bruijn n-1 , .

, , 10 ^ 3 + 2 = 1002 ( , 1000 - 1000, , , (10,3) "1000" ).

+6

Source: https://habr.com/ru/post/1779204/


All Articles