The xsim package allows to add exercises and their solutions to a LaTeX document