Solution (source code)

= Solution

A <connected space> has no expression as the union of two disjoint nonempty <open set>[open subsets]. A <continuous function>[continuous] <surjection> to the two-point <discrete topology>[discrete space] would pull back its singleton sets to such a separation. Conversely, a separation $X=U\sqcup V$ defines a <continuous function>[continuous] <surjection> by taking the values $0$ on $U$ and $1$ on $V$. Thus these two conditions are equivalent, including for the empty space.

If a subset $S\subseteq\mathbb R$ contains $a<c$ but omits some $b$ between them, its intersections with $(-\infty,b)$ and $(b,\infty)$ separate it. Hence every nonempty <connected space>[connected] subset is an <interval>. Conversely, let an <interval> $I$ have a separation and choose $a<b$ in its opposite sides. Restrict the associated two-valued <continuous function> to $[a,b]\subseteq I$ and regard it as a real-valued function. The <intermediate value theorem> forces the value $1/2$, a contradiction. Singletons and the empty set are <connected space>[connected] directly.

For the union assertion, let $u:X\to\{0,1\}$ be <continuous function>[continuous]. Each restriction $u|_{A_i}$ is constant because $A_i$ is <connected space>[connected]. Since every pair of the $A_i$ intersects, these constants agree, so $u$ is constant on $X$. There is no <continuous function>[continuous] <surjection>, and $X$ is <connected space>[connected]. The empty indexing case gives $X=\varnothing$ and is harmless.

To apply this to the plane, for each $t\in\mathbb R$ take the union of the horizontal line at height $t$ with the vertical axis. Its two lines are <connected space>[connected] and intersect; all such unions share the vertical axis and cover $\mathbb R^2$. Thus the plane is <connected space>[connected]. For the punctured plane, take, for every $r>0$, the circle of radius $r$ together with the positive horizontal ray. The circle is the <continuous image of a connected space>[continuous image] of $[0,2\pi]$, and intersects that <connected space>[connected] ray. These unions share the ray and cover $\mathbb R^2\setminus\{0\}$, so the punctured plane is <connected space>[connected] too. Translation gives the same conclusion after removing any one point.

Finally, suppose $g:\mathbb R^2\to\mathbb R$ were a <continuous function>[continuous] <injection>. Its image $I$ is a <connected space>[connected] <interval> with at least three points. Choose an interior point $c$ of $I$ and its unique preimage $p$. The restriction of $g$ to $\mathbb R^2\setminus\{p\}$ is a <continuous function>[continuous] <surjection> onto $I\setminus\{c\}$. Its domain is <connected space>[connected], whereas its image is separated by the two half-lines on either side of $c$. This contradicts preservation of <connected space>[connectedness] under <continuous image of a connected space>[continuous images]. Therefore \b[no continuous <injection> of the plane into the line exists].