Variational discretization: A new algorithm for the generator coordinate method