There exists a function $f: X\to Y$ between metric spaces $X$ and $Y$ that is not continuous but has the property that, for each closed ball $B$ of $Y$, $f^{-1}(B)$ is closed in $X$.
What is an example in support of the above statement?
Is this result true for all metric spaces $X$ and $Y$?
If I replace "Closed" with "Open" in the above problem, then the function is becoming continuous.