Automated discovery of logical gates for quantum error correction