Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. int count = 1, tempNumber, num;
  2.  
  3. readSudokuFile(sudokuArray);
  4.  
  5. while (count == 1)
  6. {
  7. bool found = false;
  8. while (!found)
  9. {
  10. num = ranNum(gen);
  11. if (sudokuArray[num] != 0)
  12. {
  13. found = true;
  14. tempNumber = sudokuArray[num];
  15. sudokuArray[num] = 0;
  16. }
  17. }
  18.  
  19. NoConstraintList* m = new NoConstraintList;
  20. std::cout << "The contents of the space before search begins" << std::endl;
  21. m->print();
  22.  
  23. // We initialise and get ready for search - search has not yet begun
  24. // DFS = depth first search
  25. DFS<NoConstraintList> searchengine(m);
  26. delete m;
  27.  
  28. count = 0;
  29. // We loop through all solutions to the constraint problem
  30. while (NoConstraintList* s = searchengine.next()) {
  31. s->print(); delete s;
  32. count++;
  33.  
  34. // all tuples (0..5, 0..5, 0..5) 216 of them
  35. }
  36.  
  37. std::cout << "\nNumber of elements: " << count;
  38.  
  39. }
  40.  
  41. sudokuArray[num] = tempNumber;
  42.  
  43. std::cout << "\n\nSudoku with only one solution: \n\n";
  44. for (int i = 0; i < SUDOKU; i++) {
  45. if (!(i % NUM)) {
  46. std::cout << '\n';
  47. }
  48. std::cout << sudokuArray[i] << " ";
  49. }
  50. std::cout << "\n\n";
  51.  
  52. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement