### NEED HELP with C++ Sudoku Solver

Pages: 12
=
Last edited on
If you're getting empty brackets, that may mean you inadvertently removed the `i != j` comparison on line 14 of `tacticOneOnSection`. It should not be possible to have an empty set.

 Is everything else in your program the same as mine?

ShowPuzzle, the tactic functions and main are the only things I changed. Of course, I don't know what you've changed since you first authored this thread.

Working code: http://ideone.com/0QNNwc
Last edited on
=
Last edited on
 Thanks, this code works great. The only problem is that it combines Tactic One and Tactic Two into the same function and i needed them to be separate functions. (Why do that when one is enough? Because my teacher is crazy specific on these programs.) The reason for them being separate is explained here:

All my code does is repeatedly run tacticOne.

 Tactic Two: Suppose that you look at all of the sets in a given row, and only one of those sets contains 2. Then, clearly, that cell must hold 2. So you change it to {2}, a singleton set. This must be done for every row, column, and 3x3 section.

This logic doesn't occur anywhere in my code. Nowhere is a cell changed to a singleton set because of the content of all other cells in the row/column/section. All we do is check to see if a cell is a singleton and remove the value it represents from all other cells in the row/column/section (ie. tactic one.)
Last edited on
=
Last edited on
Everyone's code for tactic 1 is solving tactic2 incidentally. It doesn't look possible in fact, to have a code that works for tactic 1 and will not include tactic 2.
 Everyone's code for tactic 1 is solving tactic2 incidentally.

tactic 1 is an algorithm. tactic 2 is an algorithm. They solve different problems. The latter isn't required for the puzzle given here, but will be required for some puzzles (and additional tactics will be required for more difficult puzzles.)

This one is solvable with the combination of these two tactics, for instance, but isn't solvable by either alone:

 ```9-- --- 12- --2 3-- --- 4-- --5 96- -8- 2-- 6-- --- -5- --- --1 --9 -3- -76 9-- --1 --- --1 7-- -98 --- --4```
Topic archived. No new replies allowed.
Pages: 12