In any topological space $X$, the identity function on $X$ and any constant function $X\rightarrow X$ are necessarily continuous. Does there exist an infinite topological space such that these functions are the only continuous functions $X\rightarrow X$?
I require the space to be infinite since there are finite examples such as the one-point space, and the space $\{1,2\}$ with open sets $\{\emptyset,\{1\},\{1,2\}\}$. Although I am not aware of any finite examples with more than two points, so those could be of interest to me too.
The only further progress I've made is that such a space must be connected: otherwise write $X$ as a disjoint union of nonempty open sets $U\cup V$. A map sending $U$ to one point and $V$ to a different point is then continuous.