The problem: Let $$g(x)= \left\{ \begin{matrix} x & , \, 0 \leq x \leq 1/2\\ 1-x& , \, 1/2 \leq x \leq 1 \end{matrix} \right .$$ Prove that $$S_n(x)=\sum_{k=0}^{n} \frac{g(2^kx)}{2^k}$$ converges uniformly to a continous function $f$.
My solution: Notice that $g(x)$ exist only when $x\in [0,1]$. Since $2^n \to \infty$ when $n \to \infty$, if $x>0$ then $2^nx >1$ for sufficiently large $n$, therefore for $x=0, \ \{S_n(x)\}$ converges to $f(x)=0$, and for any other value of $x, \ S_n(x)$ doesn't exist when $n\to \infty$, so $f$ is undefined. Since the uniform converges definition is true for all $x\in\{0\}$ and since $x=0$ is not an accumulation point of $f, \ \{S_n(x)\}$ converges uniformly to $f$, which is continous.
Teacher's solution: Extend the domain of $g$ such that $g(x)=g(x+1)$, then $g(x)\leq 1/2, \ \forall x\in \mathbb{R}$, so $$\frac{g(2^nx)}{2^n} < \left(\frac{1}{2}\right)^n$$ By Weiertrass' M Criterion, $\{S_n(x)\}$ converges uniformly to a function $f$ over $\mathbb{R}$ and since every $g(2^nx)/2^n$ is continous, so is $f$
Now, I don't understand why extending the domain of $g$ is valid here, isn't it like adding an extra condition that the problem doens't give?
$g$ is only defined over $[0,1]$, yet $x$ may be any real number. Extending $g$ gives definition to the cases when its argument falls outside $[0,1]$, such as $k=2$ and $x=\frac13$. Extending $g$ per the teacher's answer (periodically) makes the function behave in a more regular (read: easier to understand) way, while guaranteeing that the bounds on $\frac{g(2^kx)}{2^k}$ fall fast enough to apply the Weierstrass M-test.
$f$ is in fact the blancmange or Takagi curve. The part in $[0,1]$ is shown below: