Solution (source code)

= Solution

With the normalization used in the question, <ridge regression> solves
$$
\min_{\mu\in\mathbb R,\,\beta\in\mathbb R^p}
\bigl\|Y-\mu\mathbf1-X\beta\bigr\|_2^2+\lambda\|\beta\|_2^2.
$$
Differentiating with respect to $\mu$ and using the centered columns $X^T\mathbf1=0$ gives $\widehat\mu=\overline Y$. The <normal equation> for $\beta$ is
$$
(X^TX+\lambda I)\widehat\beta=X^TY,
$$
so
$$
\widehat\beta=(X^TX+\lambda I)^{-1}X^TY.
$$
The <push-through identity> then gives the equivalent dual form
$$
\widehat\beta=X^T(XX^T+\lambda I)^{-1}Y.
$$