Exact wavefunctions for the one-dimensional gravitational gas