An efficient calculation of the energy levels of the carbon group