void MultipleSolution() { cout << "No Unique Solution"; exit(0); } bool solutionFound = false; void CheckSolutions(vector& cells, int index) { if (index == cells.size()) { if (solutionFound == true) { MultipleSolution(); } else { solutionFound = true; } return; } for (int i = 1; i <= 9; i++) { if(cells[i]->canPutNumber(i)) { cells[i]->setNumber(i); CheckSolutions(cells, index + 1); } } // Before backtracking, better set the number back to 0 cells[index]->setNumber(0); return; } void CheckForSolutions(vector& cells) { CheckSolutions(cells, 0); if (solutionFound == false) { cout << "No Solution"; } else { cout << "Valid Puzzle"; } exit(0); }