summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--solve.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/solve.cpp b/solve.cpp
index 59c43e3..98bc7b2 100644
--- a/solve.cpp
+++ b/solve.cpp
@@ -133,6 +133,23 @@ private:
recurseone(dst);
}
+ bool verifyConsistent(bool diag=false) const {
+ for(int i=0;i<N;i++){
+ bitset<N> seenH,seenV;
+ for(int j=0;j<N;j++){
+ if(bd[i][j]!=-1){
+ if(seenH.test(bd[i][j]-1)){if(diag)cerr<<__LINE__<<": ("<<j<<','<<i<<')'<<endl; return false;}
+ seenH.set(bd[i][j]-1);
+ }
+ if(bd[j][i]!=-1){
+ if(seenV.test(bd[j][i]-1)){if(diag)cerr<<__LINE__<<": ("<<i<<','<<j<<')'<<endl; return false;}
+ seenV.set(bd[j][i]-1);
+ }
+ }
+ }
+ return true;
+ }
+
public:
Sudoku(const string &init){
static_assert(N>1&&BW>1&&BH>1&&BW*BH==N,"Box size inconsistent");
@@ -166,23 +183,6 @@ public:
return dst;
}
- bool verifyConsistent(bool diag=false) const {
- for(int i=0;i<N;i++){
- bitset<N> seenH,seenV;
- for(int j=0;j<N;j++){
- if(bd[i][j]!=-1){
- if(seenH.test(bd[i][j]-1)){if(diag)cerr<<__LINE__<<": ("<<j<<','<<i<<')'<<endl; return false;}
- seenH.set(bd[i][j]-1);
- }
- if(bd[j][i]!=-1){
- if(seenV.test(bd[j][i]-1)){if(diag)cerr<<__LINE__<<": ("<<i<<','<<j<<')'<<endl; return false;}
- seenV.set(bd[j][i]-1);
- }
- }
- }
- return true;
- }
-
bool verifySolution(const Sudoku<N,BW,BH> &sol) const {
for(int y=0;y<N;y++){
for(int x=0;x<N;x++){