Solution (source code)

= Solution

This is always true. The continuous image $f(X)$ of a <connected space> is connected. Its <closure> is also connected: if the closure were separated into disjoint nonempty relatively open sets, connectedness would put $f(X)$ inside one of them, preventing its closure from meeting the other. Since $f(X)$ is dense in $Y$, its closure is $Y$, so $Y$ is connected.