Let $\pi: \mathbb{R}^2\to \mathbb{R}$ defined by $\pi(x,y)=x$. Let $M$ be a metric space. Prove that $f:[-r,r]\to M$ is continuous if and only if $f\circ \pi: B[0,r]\to M$ is continuous on the closed ball $B[0,r]$ (considering euclidean metric in the interval and euclidean metric in $B[0,r]$).
I only prove the obvious part. In the other part I was proved using Borel-Lebesgue Theorem in a vertical segment of ball. I don't think if it is the idea of exercise because I found in a basic chapter of a book. I want a simpler answer to this fact. I think that is true when continuity is only in the open ball $B(0,r)$, in this case I can't use Borel-Lebesgue Theorem.
The next problem that I have is the following:
Show an example of a set $X\subset \mathbb{R}^2$ such that $\pi(X)=[-1,1]$ and $f:[-1,1]\to\mathbb{R}$ is not continuous but $f\circ \pi: X\to \mathbb{R}$ is continuous.
Obviously I need a subset $X$ such that has a very different topological structure that the closed ball $B[0,1]$. But I don't find it.