Solution (source code)

= Solution
{c}

Define
$$
r:M(f)\longrightarrow Y,\qquad r(q(x,t))=f(x),\quad r(i(y))=y.
$$
The two formulas agree on the attached end, so the <universal property of the quotient topology> makes $r$ a <continuous map>. Also $ri=\operatorname{id}_Y$.

Slide each cylinder point towards its attached end using
$$
K(q(x,t),s)=q(x,t+s(1-t)),\qquad K(i(y),s)=i(y).
$$
At $t=1$ these formulas both give $i(f(x))$, so they define a <homotopy> on the <mapping cylinder>. For continuity, the <product of a quotient map with the unit interval> is a <quotient map>; the formulas before taking the <quotient topology> are <continuous maps> and agree on every identified pair. Thus
$$
K(-,0)=\operatorname{id}_{M(f)},\qquad K(-,1)=ir.
$$
Moreover $Y$ stays fixed throughout. We have obtained the stronger conclusion
$$
\boxed{M(f)\text{ deformation retracts onto }Y.}
$$
In particular $r$ is the requested <homotopy retract>.