Darboux continuity of the function $f(x) = \limsup_{n \to \infty} \frac{(x_{1}+...+x_{n})^{2}}{n^{2}}$ Let $f : [0,1] \to [0,1]$ be a function that assigns to each $x \in [0,1]$ the following value:
$$ x = 0.x_{1}x_{2}x_{3} \ \ ... \hspace{0.3cm} \text{be the binary expansion of }x $$
define 
$$ f(x): = \limsup_{n \to \infty} \frac{(x_{1}+...+x_{n})^{2}}{n^{2}}$$
Prove that $f$ is Darboux continuous but not continuous.

Can someone give hint on this problem?
Thank you.
 A: Thinking of the binary expansion of $x\in [0,1]$ as infinite sequence of (fair) coin tosses implies the following:

Claim: $f(x) = \frac{1}{4}$ almost everywhere on $[0,1]$.

Indeed, consider the probability space $([0,1], \mathcal{B}([0,1]), \mu )$ where $\mathcal{B}([0,1])$ is the Borel $\sigma$-algebra of $[0,1]$ and $\mu$ is the Lebesgue measure of $[0,1]$. For each $n\in \mathbb{N}$, let $X_n :[0,1] \to \{0,1\}$ be the $n$-th bit (coordinate) of the binary expansion of $x\in [0,1]$. Notice that $X_n$ is not well-defined on dyadic rationals, however they form a set of measure (probability) $0$, thus we will ignore it without loss of generality.
Notice that $\{X_n\}_{n=1}^\infty$ is a sequence of i.i.d. random variables with $\mu(X_n = 1) = \mu(X_n = 0) = 1/2$ for all $n\in \mathbb{N}$. To see this simply follow the structure of the set $X_n = a$ where $a \in \{0,1\}$, precisely if $[0,1]$ is partitioned into intervals of the form $\Delta_i: = [i2^{-n}, (i+1)2^{-n})$, $i=0,1,...,2^n-1$, then if the set $X_n = a $ in each $\Delta_i$ is either the left half if $a=0$ or the right half if $a=1$. Using this structure the independence follows easily.
Now, the function $f$, in our new notation becomes
$$
f(\omega) = \limsup\limits_{n\to \infty} \left(\frac{X_1(\omega)+...+X_n(\omega)}{n}\right)^2, \text{ where } \omega \in [0,1].
$$
In view of the i.i.d. condition of $(X_n)$, from the strong law of large numbers we get that $f(\omega) = (\mathbb{E}X_1)^2 = 1/4$ almost surely, i.e. almost everywhere on $[0,1]$.

We next prove that the image of any dyadic interval under $f$ is the $[0,1]$. This will prove that $f$ is Darboux continuous, and coupled with the fact that $f=1/4$ a.e. will show that $f$ is nowhere continuous.

Let $\Delta_k^i: = [i/2^k,(i+1)/2^k]$ where $0\leq i \leq 2^k - 1 $ and $k=0,1,...$ . Then $f(\Delta_k^i) = [0,1]$.

To prove this, take any $0<a<1$ and consider its decimal expansion
$$
a = \sum\limits_{n=1}^\infty \frac{a_n}{10^n}, \text{ where } a_n \in \{0,1,...,9\}.
$$
Let $S_n = \sum\limits_{k=1}^n \frac{a_k}{10^k} := \frac{p_n}{10^n}$ be the $n$-th partial sum of the expansion. Here $p_n$ is a non-negative integer, and 
$$
\frac{p_n}{10^n} \to a, \tag{1}
$$
hence for $n\in \mathbb{N}$ large enough, we have
$$
\frac a2 10^n \leq p_n \leq 10^n \tag{2}
$$
Take a rapidly growing sequence of integers $n_1<n_2<...$ and define $x\in (0,1) $ with binary expansion of the form
$$
x = (b_1,...,b_{10^{n_1}}, b_{10^{n_1} + 1}, ..., b_{10^{n_2}}, ....)
$$
as follows:
in each block $(b_{10^{n_k} + 1}, ..., b_{10^{n_{k+1}}})$ take precisely $p_{n_{k+1}} -10^{n_k} $ number of $1$s and put the rest of the bits as $0$. The length of the block equals $10^{n_{k+1}} - 10^{n_k} $, hence using $(2)$, for all $k=1,2,...$ we get
$$
\frac{p_{n_k}}{10^{n_k}} - \frac{1}{10^{n_k - n_{k-1}} } \leq \frac{b_1+...+b_{10^{n_k}}}{10^{n_k}} \leq \frac{1}{10^{n_k - n_{k-1}} } + \frac{p_{n_k} - 10^{n_{k-1}}}{10^{n_k}} = \frac{p_{n_k}}{10^{n_k}}.
$$
The latter combined with $(1)$ implies that $\limsup\limits_{n\to \infty} \frac{b_1+...+b_n}{n} = a $, i.e. $f(x) = a^2$. Since $0<a<1$ is any, we get that $f([0,1]) = [0,1]$. 
To get the result for the dyadic interval $\Delta_k^i$, observe that changing finitely many bits in $x$ does not affect the value of $f(x)$. Thus, if $i=(b_1...b_k)$ is the binary representation of the integer $0\leq i\leq 2^k-1$, we simply append these bits to beginning of the binary expansion of $x$ constructed above for the given $a$ to make $x\in \Delta_k^i$, completing the proof of the claim $f(\Delta_k^i) = [0,1]$.
