For non-negative integers $x$, the function $f(x)$ is defined as follows:
$$f(0)=0, f(x)=f\left(\left[\frac{x}{10}\right]\right)+\left[\lg \frac{10}{x-10\left[\frac{x-1}{10}\right]}\right]$$
What is the value of $x$ when $f(x)$ reaches its maximum in the range $0 \leqslant x \leqslant 2006$?
1. Solution: Let $x=10 p+q$, where $p$ and $q$ are integers and $0 \leqslant q \leqslant 9$.

Then $\left[\frac{x}{10}\right]=\left[p+\frac{q}{10}\right]=p$.
Thus, $\left[\frac{x-1}{10}\right]=\left[p+\frac{q-1}{10}\right]$ has a value of $p-1$ (when $q=0$) or $p$ (when $q \neq 0$), and $x-10\left[\frac{x-1}{10}\right]$ has a value of 10 (when $q=0$) or $q$ (when $q \neq 0$),
$\left[\lg \frac{10}{x-10\left[\frac{x-1}{10}\right]}\right]$ has a value of 1 (when $q=1$) or $0$ (when $q \neq 1$).
Therefore, $f(x)=f(p)+1$ (when $q=1$) or $f(p)$ (when $q \neq 1$).
Hence, the value of $f(x)$ is the number of digit 1s in the decimal representation of $x$, so when $0 \leqslant x \leqslant 2006$, the maximum value of $f(x)$ is 4, at which point $x=1111$.