Solution (source code)

= Solution

When $X^TX=I_p$, expanding the objective separates it by coordinates:
$$
\lVert Y\rVert^2+
\sum_{j=1}^p\{(1+\lambda_2)\beta_j^2
-2(X^TY)_j\beta_j+\lambda_1|\beta_j|\}.
$$
The <soft thresholding> solution is therefore
$$
\widehat\beta_j^E
=\frac{S_{\lambda_1}((X^TY)_j)}{1+\lambda_2},
\qquad j=1,\ldots,p.
$$