Solve Every Sudoku without Guessing. Your comment are welcome. I did some promotion for this forum.
www.fileupyours.com/files/314015/Sudoku_without_Guessing.pdf {PDF}
Thanks
sdk_fan wrote:Solve Every Sudoku without Guessing. Your comment are welcome.
SudoQ wrote:Is the application using the method you describe and you refer to available?
/SudoQ
JasonLion wrote:Consider the following: match the clues against the set of all possible solution grids...
JasonLion wrote:Several algorithms are already known for solving any puzzle without guessing or trial and error.
JasonLion wrote:Yet, your approach involves enumerations of the possible positions of cogs, which look like "databases" to me. What is the logical difference between those two things?
0. Set the level to 0.
1. Solve all singles and locked candidates
2a. If the puzzle is solved, stop
2b. If the level is 0 and the puzzle has no solution (a contradiction),
there is no solution, stop
2c. If the puzzle is still unsolved, continue with 3.
2d. If the level is greater 0 and the puzzle has no solution,
decrease the level and remove the candidate set in the higher level
If this leaves a single, continue with 1.
3. Find the first cell with the minimum number of candidates.
Copy the grid (new "node"), increase the level,
set the first candidate in this cell, continue with 1.
eleven wrote:Brian made a very fast implementation in C++ in his bb_solver (bitbased, using lookup tables). It solves the 14258 extremely hard puzzles in champagne's list in 5 seconds.
>>> solve(tests['discrepancy'])
Attacking..
Starting with...
col: 1 2 3 4 5 6 7 8 9
-----------------------
r 1 | _ _ _ _ _ _ _ 3 9
r 2 | _ _ _ _ _ 1 _ _ 5
r 3 | _ _ 3 _ 5 _ 8 _ _
r 4 | _ _ 8 _ 9 _ _ _ 6
r 5 | _ 7 _ _ _ 2 _ _ _
r 6 | 1 _ _ 4 _ _ _ _ _
r 7 | _ _ 9 _ 8 _ _ 5 _
r 8 | _ 2 _ _ _ _ 6 _ _
r 9 | 4 _ _ 7 _ _ _ _ _
End with...
col: 1 2 3 4 5 6 7 8 9
-----------------------
r 1 | _ _ _ _ _ _ _ 3 9
r 2 | _ _ _ _ _ 1 _ _ 5
r 3 | _ _ 3 _ 5 _ 8 _ _
r 4 | _ _ 8 _ 9 _ _ _ 6
r 5 | _ 7 _ _ _ 2 _ _ _
r 6 | 1 _ _ 4 _ _ _ _ _
r 7 | _ _ 9 _ 8 _ _ 5 _
r 8 | _ 2 _ _ _ _ 6 _ _
r 9 | 4 _ _ 7 _ _ _ _ _
Not solved in the pre-processing. Now Using Cogwheel Method
col: 1 2 3 4 5 6 7 8 9
--------------------------------------------------------------------------
r 1 82567| 81456| 124567| 826| 2467| 8467| 1247| D 3| D 9|
--------------------------------------------------------------------------
r 2 89267| 8946| 2467| 89236| 23467| D 1| 247| 2467| D 5|
--------------------------------------------------------------------------
r 3 9267| 1469| D 3| 926| D 5| 9467| D 8| 12467| 1247|
--------------------------------------------------------------------------
r 4 235| 345| D 8| 135| D 9| 357| 123457| 1247| D 6|
--------------------------------------------------------------------------
r 5 9356| D 7| 456| 81356| 136| D 2| 13459| 8149| 8134|
--------------------------------------------------------------------------
r 6 D 1| 9356| 256| D 4| 367| 83567| 92357| 8927| 8237|
--------------------------------------------------------------------------
r 7 367| 136| D 9| 1236| D 8| 346| 12347| D 5| 12347|
--------------------------------------------------------------------------
r 8 8357| D 2| 157| 1359| 134| 9345| D 6| 81497| 81347|
--------------------------------------------------------------------------
r 9 D 4| 81356| 156| D 7| 1236| 9356| 1239| 8129| 8123|
--------------------------------------------------------------------------
Tree built for group [(6, 3), (4, 2), (4, 1), (5, 3), (6, 2), (5, 1)]
Tree built for group [(6, 3), (5, 3), (8, 3), (9, 3), (2, 3), (1, 3)]
0:14:23.518 spent, 20 leaves (paths), 2 groups engaged.
Tree built for group [(8, 3), (9, 3), (7, 1), (7, 2), (8, 1), (9, 2)]
0:00:00.026 spent, 108 leaves (paths), 3 groups engaged.
Tree built for group [(4, 2), (6, 2), (7, 2), (9, 2), (2, 2), (3, 2), (1, 2)]
0:00:00.040 spent, 198 leaves (paths), 4 groups engaged.
Tree built for group [(4, 1), (5, 1), (7, 1), (8, 1), (3, 1), (2, 1), (1, 1)]
0:00:00.043 spent, 382 leaves (paths), 5 groups engaged.
Tree built for group [(4, 2), (4, 1), (4, 8), (4, 6), (4, 4), (4, 7)]
0:00:00.056 spent, 886 leaves (paths), 6 groups engaged.
Tree built for group [(4, 6), (4, 4), (5, 5), (6, 5), (5, 4), (6, 6)]
0:00:00.246 spent, 3986 leaves (paths), 7 groups engaged.
Tree built for group [(5, 3), (5, 1), (5, 5), (5, 4), (5, 8), (5, 9), (5, 7)]
0:00:00.458 spent, 7770 leaves (paths), 8 groups engaged.
Tree built for group [(6, 3), (6, 2), (6, 5), (6, 6), (6, 8), (6, 9), (6, 7)]
0:00:00.797 spent, 16786 leaves (paths), 9 groups engaged.
Tree built for group [(5, 5), (6, 5), (8, 5), (1, 5), (9, 5), (2, 5)]
0:00:03.467 spent, 31696 leaves (paths), 10 groups engaged.
Tree built for group [(2, 3), (2, 2), (2, 1), (2, 5), (2, 7), (2, 4), (2, 8)]
0:00:03.266 spent, 40224 leaves (paths), 11 groups engaged.
Tree built for group [(4, 8), (5, 8), (6, 8), (2, 8), (9, 8), (3, 8), (8, 8)]
0:00:02.913 spent, 42622 leaves (paths), 12 groups engaged.
Tree built for group [(8, 3), (8, 1), (8, 5), (8, 8), (8, 6), (8, 4), (8, 9)]
0:00:03.860 spent, 36784 leaves (paths), 13 groups engaged.
Tree built for group [(4, 4), (5, 4), (2, 4), (8, 4), (3, 4), (1, 4), (7, 4)]
0:00:01.781 spent, 19900 leaves (paths), 14 groups engaged.
Tree built for group [(3, 2), (3, 1), (3, 8), (3, 4), (3, 9), (3, 6)]
0:00:02.125 spent, 14444 leaves (paths), 15 groups engaged.
Tree built for group [(1, 3), (1, 2), (1, 1), (1, 5), (1, 4), (1, 7), (1, 6)]
0:00:00.461 spent, 6376 leaves (paths), 16 groups engaged.
Tree built for group [(4, 6), (6, 6), (8, 6), (3, 6), (1, 6), (7, 6), (9, 6)]
0:00:00.345 spent, 3580 leaves (paths), 17 groups engaged.
Tree built for group [(7, 1), (7, 2), (7, 4), (7, 6), (7, 7), (7, 9)]
0:00:00.370 spent, 1007 leaves (paths), 18 groups engaged.
Tree built for group [(5, 9), (6, 9), (8, 9), (3, 9), (7, 9), (9, 9)]
0:00:00.135 spent, 161 leaves (paths), 19 groups engaged.
Tree built for group [(9, 3), (9, 2), (9, 5), (9, 8), (9, 6), (9, 9), (9, 7)]
0:00:00.078 spent, 33 leaves (paths), 20 groups engaged.
Tree built for group [(8, 5), (9, 5), (8, 6), (8, 4), (7, 4), (7, 6), (9, 6)]
0:00:00.041 spent, 1 leaves (paths), 21 groups engaged.
Tree built for group [(9, 8), (8, 8), (8, 9), (7, 7), (7, 9), (9, 9), (9, 7)]
0:00:00.137 spent, 1 leaves (paths), 22 groups engaged.
Tree built for group [(1, 5), (2, 5), (2, 4), (3, 4), (1, 4), (3, 6), (1, 6)]
0:00:00.046 spent, 1 leaves (paths), 23 groups engaged.
Tree built for group [(2, 3), (1, 3), (2, 2), (3, 2), (1, 2), (3, 1), (2, 1), (1, 1)]
0:00:00.130 spent, 1 leaves (paths), 24 groups engaged.
Tree built for group [(4, 8), (4, 7), (5, 8), (5, 9), (5, 7), (6, 8), (6, 9), (6, 7)]
0:00:00.130 spent, 1 leaves (paths), 25 groups engaged.
Tree built for group [(2, 7), (2, 8), (3, 8), (3, 9), (1, 7)]
0:00:00.020 spent, 1 leaves (paths), 26 groups engaged.
Tree built for group [(4, 7), (5, 7), (6, 7), (2, 7), (1, 7), (7, 7), (9, 7)]
0:00:00.060 spent, 1 leaves (paths), 27 groups engaged.
The puzzle has been decided. Time spent in the cogwheel method: 0:00:22.286000
There are 1 solutions.
Solution #1:
7 5 1 8 4 6 2 3 9
8 9 2 3 7 1 4 6 5
6 4 3 2 5 9 8 7 1
2 3 8 1 9 7 5 4 6
9 7 4 5 6 2 3 1 8
1 6 5 4 3 8 9 2 7
3 1 9 6 8 4 7 5 2
5 2 7 9 1 3 6 8 4
4 8 6 7 2 5 1 9 3
Garbage: 1051796
sdk_fan wrote:But the main point here is that I am not using backtracking.
coloin wrote:
I havnt looked at your program but i could ask how it decides where to start in the process.....
If it is able to solve without an assumptive process can you ascribe a "rating" as to how quick/how tricky/length of path etc. Of course it would have to be isomorph invarient.
eleven wrote:If i understood right,what you are doing, the main difference to Brian's method is, that you are doing a breadth first and Brian a depth first search in your trees.