int main() { Sudoku ss; int num; int i,j,k; int count = 0; while(cin >> num) { count++; if(count!=1 && ans_count != 0) cout << endl << endl; else if(count !=1) cout << endl; for(i=0; i<9; i++) { for(j=0; j<9; j++) { su[i][j] = 0; su3[i][j][0] = 0; ans[i][j] = 0; su2[i][j] = 0; for(k=1; k<10; k++) { su3[i][j][k] = 1; } } } have_zero = false; ans_count = 0; ss.readIn(num); ss.solve(num); } }
int main(){ Sudoku ss; ss.readIn(); ss.solve(); return 0; }
bool Sudoku::solve() { if(fin()){ return true; } while(1){ Move m = findMove(); if(m.val == 0){ //no more moves return false; } Sudoku scopy = *this; bool result = scopy.applyMove(m); if(!result){ cand[m.ii][m.jj][m.val] = false; continue; } result = scopy.solve(); if(result){ *this = scopy; return true; }else{ cand[m.ii][m.jj][m.val] = false; } } return false; }
void sudokuTest() { vector< vector<int> > _grid = {{3, 0, 6, 5, 0, 8, 4, 0, 0}, {5, 2, 0, 0, 0, 0, 0, 0, 0}, {0, 8, 7, 0, 0, 0, 0, 3, 1}, {0, 0, 3, 0, 1, 0, 0, 8, 0}, {9, 0, 0, 8, 6, 3, 0, 0, 5}, {0, 5, 0, 0, 9, 0, 6, 0, 0}, {1, 3, 0, 0, 0, 0, 2, 5, 0}, {0, 0, 0, 0, 0, 0, 0, 7, 4}, {0, 0, 5, 2, 0, 6, 3, 0, 0}}; Sudoku* puzzle = new Sudoku( _grid ); if(!puzzle->IsLegalBoard()) { drunkout("Illegal board.", cERROR); } puzzle->print(); if(puzzle->solve()) puzzle->print(); else drunkout("No solution.", cINFO); delete puzzle; }
/** * Main method that gets initialized upon start of the program and creates an instance of the class Sudoku. A function * belonging to the Sudoku class is called that will generate a completely solved sudoku board and then the pointer to * the class is deleted to free up the allocated memory. */ int main() { Sudoku * mySudoku = new Sudoku(); mySudoku->solve(); delete mySudoku; return 0; }
int main() { Sudoku sudoku; sudoku.readIn(); sudoku.solve(); return 0; }
int main() { Sudoku sdk; sdk.readIn(); sdk.solve(); system("PAUSE"); return 0; }
int main(int argc, const char * argv[]) { Sudoku ss; ss.readIn(); ss.solve(); return 0; }
int main(){ Sudoku ss; ss.readIn(); // ss.rotate(83); // ss.flip(1); // ss.changeNum(3,6); // ss.changeRow(0,2); // ss.changeCol(0,2); ss.solve(); return 0; }
int main() { string board; while (getline(cin, board)) { Sudoku game = board; game.print(); game.solve(); game.print(); cout << game.exportString() << endl; } return 0; }
int main(int argc, char** argv) { if (argc != 3) { puts("Format: main.out input_filename output_filename"); exit(1); } char* infilename = argv[1]; char* outfilename = argv[2]; Sudoku sudoku; sudoku.load(infilename, SUDOKUSIZE, SUDOKUUNITSIZE); sudoku.solve(); sudoku.print(outfilename); return 0; }
int main() { system("color 4B"); // sound // UINT wDeviceID; //a device ID so we can keep track of it once we open it. DWORD dwReturn; //a return value.. MCI_OPEN_PARMS mciOpenParms; //Structure for the MCI_OPEN command MCI_PLAY_PARMS mciPlayParms; //Structure for the MCI_PLAY command mciOpenParms.lpstrDeviceType = TEXT("waveaudio"); mciOpenParms.lpstrElementName = TEXT("mortal.wav"); if (dwReturn = mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)(LPVOID)&mciOpenParms)) { cout << "sound file unavailable.\n"; } // The device opened successfully; get the device ID. wDeviceID = mciOpenParms.wDeviceID; if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, 0, NULL)) { mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL); return (dwReturn); } // Establish Local variables string master_loop = "y", inputFile; int in_value; // Create pointer to Sudoku Class Sudoku *solution; do // Start of master_loop { cout << "\n*===*===*===*===*===*===*===*===*===*===*===*===*===*===*" << "\n|\t\t\t\t\t\t\t|" << endl; cout << "|\t\t\t FIGHTING \t\t|" << "\n|\t\t\t\t\t\t\t|" << endl; cout << "| ///// // // //// ////// // // // // |" << endl; cout << "| * // // // // / // // // // // // * |" << endl; cout << "| ** ///// // // // / // // /// // // ** |" << endl; cout << "| * // // // // / // // // // // // * |" << endl; cout << "| ///// ////// //// ////// // // ////// |" << endl; cout << "|\t\t\t\t\t\t TM \t|" << "\n|\t\t\t\t\t\t\t\|" << endl; cout << "| * Anthony * Chad * Jason * Michael * Scott * |" << endl; cout << "*===*===*===*===*===*===*===*===*===*===*===*===*===*===*" << endl; // Ask the user to input the path to or a file name cout << "\n\nYou must input a Sudoku Fighting file name: "; // Read in user input assign the variable cin >> inputFile; // Attempt to open the file fstream inFile(inputFile); // If file can not open if (!inFile) { cout << "\nHA!!!!, your puny file "<< inputFile << " is not detected. \nYou have to enter it correctly to fight. \nTry again.\n" << endl; system("PAUSE"); system("CLS"); } // If the file is found continue on with program else { // Create new Sudoku Solution solution = new Sudoku; // Read data into Sudoku while (inFile >> in_value) { solution->fill_board(in_value); } // Print inputed Sudoku puzzle solution->print_Board(); // Pause to allow user to view inputed Sudoku puzzle cout << "\n\nAre you ready to Fight?\n" << endl; system("PAUSE"); // Call Sudoku Solution solution->solve(0, 0); // Print solved Sudoku puzzle solution->print_Board(); // Conclusion mciOpenParms.lpstrElementName = TEXT("flawless.wav"); cout << "\n\n\Hooozah! That's why they call me the Sudoku Fighter.\n" << endl; do { // Ask user if they would like to try the program again cout << "Would you like to fight again? (y) or (n): "; // Read input cin >> master_loop; // If not valid reponse explain, and promt user to try again if (master_loop != "y" && master_loop != "n") { cout << "\nHA!!!, " << master_loop << " Your fighting skills are not up to par. \nTry again if you are brave enough.\n" << endl; system("PAUSE"); } // While loop to ensure that only "y" or "n" is inputed. } while (master_loop != "y" && master_loop != "n"); } system("CLS"); // If user inputs "y" master_loop repeats, if user inputs "n" Program ends } while (master_loop == "y"); } // End main()