Fixed issues

master
Hecht 2 years ago
parent 14013de668
commit 1bf495d9dc

@ -1,537 +0,0 @@
┌───────┬───────┬───────┐
| 8 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 | | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
65 --> Point { x: 0, y: 1, s: 0 } has only 3 possibilities
┌───────┬───────┬───────┐
| 8 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 | | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
65 --> Probe Point { x: 2, y: 5, s: 3 } 128
63 --> Point { x: 3, y: 7, s: 7 } has only 3 possibilities
┌───────┬───────┬───────┐
| 8 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 8 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
63 --> Probe Point { x: 2, y: 0, s: 0 } 16
58 --> Point { x: 0, y: 1, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 5 | | |
| | 6 3 8 | 5 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 5 | | 9 |
| | | 5 |
| 9 8 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | 5 |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
58 --> Probe Point { x: 6, y: 3, s: 5 } 128
56 --> Point { x: 0, y: 1, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 5 | | |
| | 6 3 8 | 5 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 5 | | 8 9 |
| | 8 | 5 |
| 9 8 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | 5 |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
56 --> Probe Point { x: 0, y: 7, s: 6 } 128
55 --> Point { x: 0, y: 1, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 5 | | |
| | 6 3 8 | 5 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 5 | | 8 9 |
| | 8 | 5 |
| 9 8 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | 5 |
| 8 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
55 --> Probe Point { x: 1, y: 2, s: 0 } 256
51 --> Point { x: 0, y: 1, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 5 | | 9 |
| | 6 3 8 | 5 4 1 |
| 9 | 5 | |
├───────┼───────┼───────┤
| 5 | | 8 9 |
| | 9 8 | 5 |
| 9 8 | 5 | |
├───────┼───────┼───────┤
| 9 | 8 2 | 5 |
| 8 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
51 --> Probe Point { x: 0, y: 4, s: 3 } 64
65 --> Probe Point { x: 2, y: 5, s: 3 } 64
63 --> Point { x: 5, y: 1, s: 1 } has only 3 possibilities
┌───────┬───────┬───────┐
| 8 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
63 --> Probe Point { x: 2, y: 0, s: 0 } 2
59 --> Point { x: 0, y: 1, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 2 | | |
| | 6 3 8 | 2 4 1 |
| | 5 2 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
63 --> Probe Point { x: 2, y: 0, s: 0 } 1
62 --> Point { x: 3, y: 0, s: 1 } has only 3 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
62 --> Probe Point { x: 5, y: 4, s: 4 } 64
60 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | 9 7 | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
60 --> Probe Point { x: 0, y: 7, s: 6 } 64
57 --> Point { x: 4, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | 9 7 | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 7 2 | |
| 7 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
57 --> Probe Point { x: 6, y: 3, s: 5 } 4
51 --> Point { x: 5, y: 8, s: 7 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | 2 | 3 9 7 |
| | 9 7 | 5 |
| 9 7 | 3 5 | |
├───────┼───────┼───────┤
| | 8 7 2 | |
| 7 5 | 1 9 | |
| | 4 5 | 9 7 |
└───────┴───────┴───────┘
51 --> Probe Point { x: 0, y: 4, s: 3 } 8
50 --> Point { x: 4, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | 2 | 3 9 7 |
| 4 | 9 7 | 5 |
| 9 7 | 3 5 | |
├───────┼───────┼───────┤
| | 8 7 2 | |
| 7 5 | 1 9 | |
| | 4 5 | 9 7 |
└───────┴───────┴───────┘
50 --> Probe Point { x: 8, y: 2, s: 2 } 256
43 --> Point { x: 0, y: 2, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 4 9 | |
| | 6 3 8 | 4 1 |
| | 5 2 1 | 9 |
├───────┼───────┼───────┤
| | 2 4 | 3 9 7 |
| 4 | 9 7 | 5 |
| 9 7 | 3 5 | |
├───────┼───────┼───────┤
| | 8 7 2 | |
| 7 5 | 1 9 | |
| | 4 5 | 9 7 |
└───────┴───────┴───────┘
43 --> Probe Point { x: 1, y: 6, s: 6 } 4
36 --> Point { x: 1, y: 3, s: 3 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 4 9 | |
| 9 | 6 3 8 | 7 4 1 |
| 7 4 | 5 2 1 | 9 |
├───────┼───────┼───────┤
| | 2 4 | 3 9 7 |
| 4 3 | 9 7 | 5 |
| 9 7 | 3 5 | |
├───────┼───────┼───────┤
| 3 9 | 8 7 2 | |
| 7 5 | 1 9 | |
| | 4 5 | 9 7 |
└───────┴───────┴───────┘
36 --> Probe Point { x: 8, y: 7, s: 8 } 4
31 --> Point { x: 0, y: 6, s: 6 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 7 4 9 | |
| 9 | 6 3 8 | 7 4 1 |
| 7 4 | 5 2 1 | 9 |
├───────┼───────┼───────┤
| | 2 4 | 3 9 7 |
| 4 3 | 9 7 | 5 |
| 9 7 | 3 5 | 4 |
├───────┼───────┼───────┤
| 3 9 | 8 7 2 | |
| 7 5 | 1 9 6 | 4 3 |
| | 4 5 3 | 9 7 |
└───────┴───────┴───────┘
31 --> Probe Point { x: 0, y: 0, s: 0 } 32
62 --> Probe Point { x: 5, y: 4, s: 4 } 32
59 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
59 --> Probe Point { x: 0, y: 3, s: 3 } 128
57 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 8 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
57 --> Probe Point { x: 6, y: 5, s: 5 } 4
56 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 8 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 3 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
56 --> Probe Point { x: 6, y: 7, s: 8 } 128
53 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 8 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 8 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 3 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | 8 |
| 8 | 4 5 | 9 |
└───────┴───────┴───────┘
53 --> Probe Point { x: 0, y: 0, s: 0 } 64
38 --> Point { x: 6, y: 0, s: 2 } has only 2 possibilities
┌───────┬───────┬───────┐
| 7 8 1 | 2 4 9 | |
| 5 | 6 3 8 | 7 4 1 |
| | 5 1 7 | 2 8 9 |
├───────┼───────┼───────┤
| 8 5 | 3 4 | 9 |
| | 9 6 | 5 |
| 9 7 | 1 5 | 3 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 7 9 | 8 |
| 8 | 4 5 | 9 |
└───────┴───────┴───────┘
59 --> Probe Point { x: 0, y: 3, s: 3 } 32
57 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
57 --> Probe Point { x: 6, y: 5, s: 5 } 4
56 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 3 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
56 --> Probe Point { x: 8, y: 2, s: 2 } 256
54 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 9 | |
| | 6 3 | 4 1 |
| | 5 | 9 |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 3 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
54 --> Probe Point { x: 6, y: 7, s: 8 } 1
35 --> Point { x: 7, y: 6, s: 8 } has only 2 possibilities
┌───────┬───────┬───────┐
| 4 8 1 | 7 2 9 | |
| 5 | 6 3 8 | 4 1 |
| | 5 1 4 | 9 |
├───────┼───────┼───────┤
| 6 2 5 | 1 3 | 9 |
| | 9 6 | 5 |
| 9 4 7 | 2 8 5 | 3 1 6 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 3 9 7 | 1 |
| | 4 5 1 | 9 |
└───────┴───────┴───────┘
57 --> Probe Point { x: 6, y: 5, s: 5 } 2
56 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 |
├───────┼───────┼───────┤
| | 8 6 2 | |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
56 --> Probe Point { x: 8, y: 0, s: 2 } 256
54 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | | 9 |
| | 6 3 | 4 1 |
| | 5 | |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 |
├───────┼───────┼───────┤
| | 8 6 2 | 5 |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
54 --> Probe Point { x: 8, y: 7, s: 8 } 32
45 --> Point { x: 6, y: 2, s: 2 } has only 2 possibilities
┌───────┬───────┬───────┐
| 5 8 1 | | 6 3 9 |
| | 6 3 8 | 5 4 1 |
| | 5 1 9 | |
├───────┼───────┼───────┤
| 6 5 | | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 6 |
├───────┼───────┼───────┤
| | 8 6 2 | 5 |
| 5 | 9 | 6 |
| | 4 5 | 9 |
└───────┴───────┴───────┘
45 --> Probe Point { x: 6, y: 3, s: 5 } 128
41 --> Point { x: 3, y: 0, s: 1 } has only 2 possibilities
┌───────┬───────┬───────┐
| 5 8 1 | | 6 3 9 |
| | 6 3 8 | 5 4 1 |
| | 5 1 9 | 7 |
├───────┼───────┼───────┤
| 6 5 | | 8 9 |
| | 9 6 | 1 5 |
| 9 7 | 8 5 | 2 6 |
├───────┼───────┼───────┤
| | 8 6 2 | 5 |
| 5 | 9 | 6 |
| | 4 5 | 9 |
└───────┴───────┴───────┘
41 --> Probe Point { x: 1, y: 8, s: 6 } 64
36 --> Point { x: 6, y: 7, s: 8 } has only 2 possibilities
┌───────┬───────┬───────┐
| 5 8 1 | | 6 3 9 |
| 7 | 6 3 8 | 5 4 1 |
| 6 | 5 1 9 | 7 |
├───────┼───────┼───────┤
| 6 5 | | 8 9 |
| | 9 6 | 1 5 |
| 9 7 | 8 5 | 2 6 |
├───────┼───────┼───────┤
| | 8 6 2 | 7 5 |
| 5 | 9 | 6 |
| 7 6 | 4 5 | 9 |
└───────┴───────┴───────┘
56 --> Probe Point { x: 8, y: 0, s: 2 } 64
48 --> Point { x: 8, y: 3, s: 5 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 2 4 9 | 7 |
| | 6 3 | 4 1 |
| | 5 | 2 9 |
├───────┼───────┼───────┤
| 6 5 | 4 | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 |
├───────┼───────┼───────┤
| | 8 6 2 | 5 |
| 5 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
48 --> Probe Point { x: 2, y: 7, s: 6 } 8
46 --> Point { x: 2, y: 2, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 2 4 9 | 7 |
| | 6 3 | 4 1 |
| | 5 | 2 9 |
├───────┼───────┼───────┤
| 6 5 | 4 | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 |
├───────┼───────┼───────┤
| | 8 6 2 | 4 5 |
| 5 4 | 9 | |
| | 4 5 | 9 |
└───────┴───────┴───────┘
46 --> Probe Point { x: 8, y: 7, s: 8 } 2
45 --> Point { x: 2, y: 2, s: 0 } has only 2 possibilities
┌───────┬───────┬───────┐
| 8 1 | 2 4 9 | 7 |
| | 6 3 | 4 1 |
| | 5 | 2 9 |
├───────┼───────┼───────┤
| 6 5 | 4 | 9 |
| | 9 6 | 5 |
| 9 7 | 5 | 2 |
├───────┼───────┼───────┤
| | 8 6 2 | 4 5 |
| 5 4 | 9 | 2 |
| | 4 5 | 9 |
└───────┴───────┴───────┘
45 --> Probe Point { x: 6, y: 4, s: 5 } 4
┌───────┬───────┬───────┐
| 5 8 1 | 2 4 9 | 6 3 7 |
| 7 9 2 | 6 3 8 | 5 4 1 |
| 4 6 3 | 5 1 7 | 8 2 9 |
├───────┼───────┼───────┤
| 6 3 5 | 1 2 4 | 7 9 8 |
| 1 2 8 | 9 7 6 | 3 5 4 |
| 9 4 7 | 3 8 5 | 2 1 6 |
├───────┼───────┼───────┤
| 3 1 9 | 8 6 2 | 4 7 5 |
| 8 5 4 | 7 9 3 | 1 6 2 |
| 2 7 6 | 4 5 1 | 9 8 3 |
└───────┴───────┴───────┘
Solver found a solution for this sudoku!!
┌───────┬───────┬───────┐
| 5 8 1 | 2 4 9 | 6 3 7 |
| 7 9 2 | 6 3 8 | 5 4 1 |
| 4 6 3 | 5 1 7 | 8 2 9 |
├───────┼───────┼───────┤
| 6 3 5 | 1 2 4 | 7 9 8 |
| 1 2 8 | 9 7 6 | 3 5 4 |
| 9 4 7 | 3 8 5 | 2 1 6 |
├───────┼───────┼───────┤
| 3 1 9 | 8 6 2 | 4 7 5 |
| 8 5 4 | 7 9 3 | 1 6 2 |
| 2 7 6 | 4 5 1 | 9 8 3 |
└───────┴───────┴───────┘

@ -39,7 +39,6 @@ struct SolverBoard {
arr: [[u16; VALUES]; VALUES],
todos: TodoType<Point>,
valid: bool,
audit: Vec<Action>,
}
enum SolverBoardItem {
@ -130,7 +129,7 @@ impl SolverBoard {
.map(|idx| Point::from_index(idx))
.collect::<TodoType<_>>();
SolverBoard { arr: [[0x1FFu16; VALUES]; VALUES], todos: points, valid: true, audit: Vec::new()}
SolverBoard { arr: [[0x1FFu16; VALUES]; VALUES], todos: points, valid: true}
}
pub fn from(pg: &Board) -> SolverBoard {
@ -253,9 +252,6 @@ impl SolverBoard {
if let Action::Probe(_,_) = action {
self.solve_logically();
}
self.audit.push(action);
}
#[inline]
@ -376,8 +372,11 @@ impl SolverBoardIterator {
let mut excludes_ref = excludes_ref; // re-label
let excludes = Rc::make_mut(&mut excludes_ref);
// we always start with a high index??
assert!(board_ref.valid);
// extend the current exclude list by the exceeded actions in the list (before the own index)
actions.iter().rev().take(index)
actions.iter().take(index)
.for_each(|action| {excludes.insert(action.clone());});
self.stack.push(SolverBoardItem::Process(Rc::clone(&board_ref), Rc::clone(&excludes_ref), actions[index].clone()));
@ -388,8 +387,7 @@ impl SolverBoardIterator {
let mut board_ref = board_ref; // re-label
let board = Rc::make_mut(&mut board_ref);
// println!(" {} --> Probe {:?} {:?}", board.todos.len(), action.get().0, action.get().1);
// println!(" {} --> {:?}", board.todos.len(), action);
board.apply(action);
if !board.valid || !self.cache.insert(board.arr) {
@ -405,8 +403,8 @@ impl SolverBoardIterator {
let actions = Rc::new(board.get_all_actions());
actions.iter()
.rev()
.enumerate()
.rev() //
.filter(|it| !excludes.contains(it.1))
.for_each(|it| self.stack.push(SolverBoardItem::Prepare(Rc::clone(&board), Rc::clone(&excludes), Rc::clone(&actions), it.0)))
}

Loading…
Cancel
Save