- Code: Select all
000000019300600000000000000600080500040000300000010000480000070000200400010900000
2578 2567 245678 |34578 23457 234578 |2678 1 9
3 2579 1245789 |6 24579 1245789 |278 2458 24578
125789 25679 12456789 |134578 234579 12345789 |2678 234568 2345678
--------- --------- ---------+--------- --------- ---------+--------- --------- ---------
6 2379 12379 |347 8 23479 |5 249 1247
125789 4 125789 |57 25679 25679 |3 2689 12678
25789 23579 235789 |3457 1 2345679 |26789 24689 24678
--------- --------- ---------+--------- --------- ---------+--------- --------- ---------
4 8 23569 |135 356 1356 |1269 7 12356
579 35679 35679 |2 3567 135678 |4 35689 13568
257 1 23567 |9 34567 345678 |268 23568 23568
1) r7c7 <= 1 hidden single in c7
2) r8c6 <= 1 hidden single in b8
3) r3c4 <= 1 hidden single in b2
4) r2c3 <= 1 hidden single in b1
5) r5c1 <= 1 hidden single in b4
6) r4c9 <= 1 hidden single in b6
7) r9c6 <= 8 hidden single in b8
8) r1c4 <= 8 hidden single in b2
9) r9c5 <= 4 hidden single in b8
10) r8c5 <= 7 hidden single in b8
11) r8c8 <= 9 hidden single in b9
12) r6c7 <= 9 hidden single in b6
13) r7c3 <= 9 hidden single in b7
14) r4c2 <= 9 hidden single in b4
15) r3c1 <= 9 hidden single in b1
16) r3c3 <= 8 hidden single in b1
17) r1c3 <= 4 hidden single in b1
18) r6c1 <= 8 hidden single in b4
19) r8c9 <= 8 hidden single in b9
20) r5c8 <= 8 hidden single in b6
21) r2c7 <= 8 hidden single in b3
22) r7c9 <= 2 hidden single in r7
23) r8c1 <= 5 direct hidden pair r8c23.<36>
24) r8c3 <= 6 direct hidden pair r9c13.<27>
25) r8c2 <= 3 full house in r8
26) r9c7 <= 6 direct hidden pair r9c89.<35>
27) r1c2 <= 6 hidden single in r1
28) r3c6 <= 4 direct hidden pair b3x89.<36>
29) r2c6 <= 7 direct hidden pair r1c56.<35>
30) r2c5 <= 9 hidden single in b2
31) r5c6 <= 9 hidden single in b5
32) r3c5 <= 2 direct hidden pair r1c56.<35>
33) r5c3 <= 2 hidden single in r5
34) r9c1 <= 2 hidden single in b7
35) r1c1 <= 7 full house in c1
36) r9c3 <= 7 full house in b7
37) r2c2 <= 2 hidden single in b1
38) r3c2 <= 5 full house in b1
39) r6c2 <= 7 full house in c2
40) r1c7 <= 2 hidden single in b3
41) r3c7 <= 7 full house in c7
42) r6c3 <= 5 hidden single in b4
43) r4c3 <= 3 full house in c3
44) r5c9 <= 7 hidden single in b6
45) r4c4 <= 7 hidden single in b5
46) r6c4 <= 4 hidden single in b5
47) r6c6 <= 3 hidden single in b5
48) r1c5 <= 3 hidden single in b2
49) r1c6 <= 5 full house in r1
50) r4c6 <= 2 hidden single in b5
51) r4c8 <= 4 full house in r4
52) r7c6 <= 6 full house in c6
53) r2c9 <= 4 hidden single in b3
54) r2c8 <= 5 full house in r2
55) r5c5 <= 6 hidden single in b5
56) r5c4 <= 5 full house in r5
57) r7c4 <= 3 full house in c4
58) r7c5 <= 5 full house in c5
59) r6c8 <= 2 hidden single in b6
60) r6c9 <= 6 full house in r6
61) r3c8 <= 6 hidden single in b3
62) r3c9 <= 3 full house in r3
63) r9c8 <= 3 full house in c8
64) r9c9 <= 5 full house in r9
764835219321697854958124763693782541142569387875413926489356172536271498217948635 puzzle 1 givens 17 score 2.0 0.1156 ms
Alpha (x86_64-w64-mingw32-g++) Sudoku Explainer C++ engine ver 1.0 C:\msys\home\Paul\scorer\sudoku.exe -bv -E1
1 out of 1 solved leaving 0 unsolved using 0 queues size 0 17.00 avg givens 2.00 avg scores
total cpu time = 0.2379 milliseconds
solving rate = 4204.2807 puzzles/second
0.2379 msecs/puzzle
full_house updates/calls 18/64 28.13% eff 0.0226 msec tot 0.0004 msec/call 0.0013 msec/update
hidden_single_box updates/calls 36/46 78.26% eff 0.0354 msec tot 0.0008 msec/call 0.0010 msec/update
hidden_single updates/calls 4/10 40.00% eff 0.0088 msec tot 0.0009 msec/call 0.0022 msec/update
direct_pointing updates/calls 0/6 0.00% eff 0.0062 msec tot 0.0010 msec/call 1.#INF msec/update
direct_claiming updates/calls 0/6 0.00% eff 0.0102 msec tot 0.0017 msec/call 1.#INF msec/update
direct_hidden_pair updates/calls 6/6 100.00% eff 0.0244 msec tot 0.0041 msec/call 0.0041 msec/update
Now enter the puzzle into SE and manually advance using F2
- Code: Select all
000000019300600000000000000600080500040000300000010000480000070000200400010900000
I agree 100% up to the first direct hidden pair, after which SE somehow misses the 1st available one, finds the second one (in my solution path), skips the others and instead finds a higher (2.6) rated pointing locked pair. The net result is that instead of the lower 2.0 final rating by finding all the available direct hidden pairs, SE over rates this puzzle at 2.6.
So, I've become frustrated with trying to exactly match SE and instead decided to fall back to what my professor of CS 101 said regarding code optimization: "Look for the low hanging fruit!" So, here's the top 20 after profiling the current SE java source code in NetBeans:
- Code: Select all
Hot Spots - Method Self time [%] Self time Invocations
diuf.sudoku.Grid$Region.getPotentialPositions 56.53 772589.631 ms 131739038
diuf.sudoku.solver.rules.AlignedExclusion.getHints 9.82 134161.571 ms 453
diuf.sudoku.solver.rules.chaining.Chaining.getOnToOff 4.86 66360.479 ms 6497399
diuf.sudoku.Cell.getHouseCells 3.26 44596.633 ms 8657946
diuf.sudoku.solver.rules.chaining.Chaining.getOffToOn 3.01 41145.584 ms 24638899
diuf.sudoku.Cell.hasPotentialValue 2.96 40485.213 ms 1390827357
diuf.sudoku.Cell.copyTo 2.18 29836.832 ms 91877490
diuf.sudoku.solver.rules.chaining.ChainingHint.getChain 1.64 22423.427 ms 3060167
diuf.sudoku.Grid.getRegionAt 1.24 16900.163 ms 134328003
diuf.sudoku.solver.rules.chaining.ChainingHint.getAncestorCount 1.13 15495.180 ms 2460304
diuf.sudoku.Grid$Block.getCell 1.01 13859.998 ms 552213743
diuf.sudoku.tools.Permutations.nextBitNums 0.93 12695.616 ms 82641432
diuf.sudoku.solver.rules.chaining.Chaining.doChaining 0.91 12452.146 ms 565297
diuf.sudoku.Grid$Column.getCell 0.83 11394.673 ms 549626542
diuf.sudoku.tools.LinkedSet.contains 0.81 11038.626 ms 68192762
diuf.sudoku.Grid$Row.getCell 0.76 10328.371 ms 548850347
diuf.sudoku.Grid.copyTo 0.73 9964.736 ms 1134290
diuf.sudoku.solver.rules.chaining.Chaining.doForcingChains 0.61 8321.746 ms 529516
diuf.sudoku.solver.rules.chaining.Potential.hashCode 0.58 7904.065 ms 345755845
So, the biggest "bang for the buck" is to improve GetPotentialCandidates. But, that means changing the Grid and Region objects to implement a better structure for tracking candidate values. In my C++ grid object, I retain the 4 spaces (RC, RN, CN, BN) as 9x9 arrays of integers with each integer containing the 9 bits to fully define each 9x9x9 or 729 bit full view. This incurs some additional overhead during candidate assignments/eliminations, but pays off in spades during all subsequent algorithms for detecting things such as the GetPotentialCandidates. I'm starting to think that if you really want to retain an exact replication of SE scoring, then attacking the low hanging fruit (in addition to running X64 Java if you have a 64 bit OS) is the way to go.
Cheers,
Paul