The following is an interview question.
Consider a $10$-digit number where first digit is the number of zeros, second digit is the number of ones, etc. What is the number?
I know that the question is related to self-descriptive number and the answer is $$6210001000.$$ However, I do not know how to deduce the answer.
From the question, we know that the sum of all digits is $10$ as there are $10$ digits. But other than this equation, what can we obtain?
Let the number to be $k_0k_1k_2\dots k_9$ so that there're $k_0$ zeros in the number, etc.
First we know that $k_6+k_7+k_8+k_9\le 1$ since there're total only 10 digits. So we know $k_0 \ge 3$.
If $k_6+k_7+k_8+k_9=0$, we must have $k_0=4$ or $k_0=5$
So there's at most one 0 among $k_0,k_1,k_2,k_3,k_4,k_5$ since 4 zeros have been used by $k_6,k_7,k_8,k_9$. since $0*any+1*1+2*1+3*1+4*1=10$ and there're total only 10 digits, the only possible case is $k_5=0,k_4=k_3=k_2=k_1=1, k_0=any$, so $k_0=6$ but it doesn't match the assumption that $k_0=4$ or $k_0=5$
If $k_6+k_7+k_8+k_9=1$, since $k_2\le 5, k_3\le 3, k_4\le 2,k_5\le 2$, we must have $k_1\ge 6$ or $k_0\ge 6$.
If $k_1\ge 6$, since we also have $k_0\ge 3$, so $k_2+k_3+k_4+k_5\le 1$, it means that there're at least 3 zeros among $k_2,k_3,k_4,k_5$ so that $k_0 \ge 6$. It is invalid again since $k_1+k_0\gt 10$ now.
So we must have $k_0\ge 6$ and $k_6+k_7+k_8+k_9=1$ and $k_1+k_2+k_3+k_4+k_5\le 3$ and $k_1\ge 1$.
Since there're exact 3 zeros among $k_6,k_7,k_8,k_9$, there must be at least 3 zeros among $k_1,k_2,k_3,k_4,k_5$ so that at most two of them are non-zero and $k_1$ is non-zero.
If all four of $k_2,k_3,k_4,k_5$ are zeros, we have $k_0=7,k_7=1$. If $k_1=1$, there'll be two 1s ($k_1=k_7=1$); but if $k_1\gt 1$, only $k_7=1$. Both are invalid.
So there must be three of $k_2,k_3,k_4,k_5$ are zeros so that $k_0=6, k_6=1, k_7=k_8=k_9=0$. $k_4=k_5=0$ now too since only 3 non-zero digit left. Now we have $k_1+k_2+k_3=10-6-1=3$ and $k_1\ge 1, k_2+k_3\ge 1$
If $k_1=1$, we have $k_0=6,k_1=1,k_6=1$, it is invalid So $k_1=2$, we have $k_0=6, k_1=2, k_2=1, k_6=1$ and all others are zero and it is the only valid solution.