Algorithmic decomposition for efficient multiple nuclear spin detection in diamond