Let $f\colon X \to Y$ and $g \colon Y \to X$ be maps such that $g \circ f \simeq \mathrm{id}_X$, and suppose $Y$ ix a CW complex. Then show that $X$ has the homotopy type of a CW complex
This is an exercise in May's Concise Course in Algebraic Topology that's stumped me.
See Theorem 3.6.3 here. The proof is quite long (4.5 pages) and would not be appropriate for reproduction at MSE. (I am well-aware of and, in general, agree with, the policy that one should not provide "link only" answer. However, in this case, link-only seems to be the only reasonable option.)
Edit: See also Proposition A.11 in Hatcher's "Algebraic Topology".
So that the answer is a bit more self-contained, here is a sketch of the proof given in Hatcher's book:
If $X_1 \xrightarrow{f_1} X_2 \xrightarrow{f_2} X_3 \to ...$ is a sequence of composable maps, let $T(f_1, f_2, \dots)$ denote the mapping telescope (aka homotopy direct limit). The proof uses the following three elementary facts about the mapping telescope:
Then:
$$T(fg, fg, fg\dots) \simeq T(f,g,f,g\dots) \simeq T(g,f,g\dots) \simeq T(gf,gf,gf\dots).$$ Since $gf \simeq \operatorname{id}$, $T(gf,gf\dots) \simeq T(\operatorname{id}, \operatorname{id}\dots) = X \times [0, \infty) \simeq X$.
On the other hand, $fg \simeq h : Y \to Y$ where $h$ is a cellular map (cellular approximation theorem), and then $T(fg,fg\dots) \simeq T(h,h\dots)$ is a CW-complex (because $h$ is cellular). So $X$ has the homotopy type of a CW complex.