Fixed Points of Self-Referential Function of Various Lengths Note: The following question is based on a discussion I had in the comments of this question. The function I'll define is a generalization of the function given in that problem.
Fix some $n$. Then define the function $f_n : \mathbb{N}^n \to \mathbb{N}^n$ on $n$-tuples of natural numbers as follows:

*

*The first element of $f_n(\bf{x})$ is the number of distinct values appearing in the tuple $\bf{x}$.

*For $j > 1$, the $j$th element of the tuple $f_n(\bf{x})$ is the number of times $j-2$ appears in $\bf{x}$.

So, the second element of the tuple $f_n(\bf{x})$ is the number of zeroes in $\bf{x}$, the third element is the number of ones, and so on. As an example of computing this function, consider
$$f_5(2, 3, 2, 0, 0) = (3, 2, 0, 2, 1)$$
The $3$ in the answer comes from there being three distinct digits in the input $\{0, 2, 3\}$. The next elements come from: "there are two 0's in the input", "there are zero 1's in the input", "there are two 2's in the input", and "there is one 3 in the input".
Now, the question is: what are the fixed points of this function $f_n$, i.e. what values of $\bf{x}$ make $f_n(\bf{x}) = \bf{x}$?
We can immediately reduce this problem to a finite number of cases, because everything in the image of $f_n$ consists only of tuples whose maximum value is $n$. That is to say, we can compute the fixed points directly. Now, I've written a handy script to compute all of the fixed points for $n \leq 30$, and it's from this that I want to present the theorem. $n \leq 11$ seems to be mostly chaos, but when $n \geq 12$, a pattern starts to emerge.

Theorem: For $n \geq 12$, there are exactly two fixed points of $f_n$. The two fixed points are exactly $\bf{x}$ and $\bf{y}$ as follows:

*

*${\bf x} = (5, n - 6, 3, 0, 1, 0, 1, \dots, 1, 0, 0, 0, 0)$

*${\bf y} = (5, n - 6, 2, 2, 0, 0, 1, \dots, 1, 0, 0, 0, 0)$
where the omitted $(\dots)$ consists only of zeroes.

As I said, I've verified this on the computer for $12 \leq n \leq 30$. It would be interesting to have a general proof of this statement, or a refutation.
 A: Fix $n$ and let $(s,a_0,....,a_{n-2})$ be a fixed point. The key is in considering the largest number apart from $s$ and $a_0$. So let $k > 0$ such that $a_k \geq a_i$ for all $i>0$. Then in particular $a_{a_k} >0$ as well as possibly $a_{a_0} > 0$ and $a_s>0$, but for all other $i>a_k$, we have $a_i=0$, otherwise it wouldn't be the largest. So in particular there are at most only $a_k+4$ nonzero entries.
Assume $a_k > 7$. Then the value $k$ can occur for $s,a_0,a_k$ but also has to for at least $a_k-3 > 4$ other $a_i$ with $i>0$. So apart from $a_k$ occurrences of $k$, we have more than 4 other non-zero numbers which all occur at least once, so more than $a_k+4$ numbers in total, which is a contradiction.
So in particular $a_k \leq 6$ and thus there are at most 10 non-zero entries, one which, namely $a_{a_0}=1$, can be far up, but the others have to be in the beginning, among the first 10. From this one could already brute-force the solutions, or argue with symmetry:
As long as say $n> 20$, we have to have $a_0 > 10$, while all other $a_i$ and $s$ have to be below 10 as they are bounded by the number of nonzero digits. Thus taking a solution for $n$, adding 1 to $a_0$, shifting the one from $a_{a_0}$ to its new position and appending a $0$ in the end will produce a solution for $n+1$ as it doesn't change any counts except the number of zeros and the number representing $a_0$, all of which fit after the operation. The same is true in reverse. Each solution for $n$ is thus in a 1:1 relation with a solution for $n+1$, which together with the numerical result for $n=20$ proves the theorem.
There is also room for improvement in this argument. For example applying it to itself for large enough $n$, we get that $a_0> k$ which should immediately allow us to strengthen the result to $a_k \leq 5$ and there are probably some other tricks so that one can finde the only two solutions without a computer.
