Solution (source code)

= Solution

Let $S=\{0\}\cup\{1/n:n\ge1\}$ and let $D$ be the Dirichlet <function>, equal to $1$ on rationals and $0$ on irrationals. Then $f(x)=d(x,S)D(x)$ is continuous exactly on $S$: the distance factor squeezes it to zero on $S$, while away from $S$ it is a positive continuous factor times an everywhere-discontinuous <function>.