summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-10-28 23:16:33 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-28 23:16:33 +0200
commit13b7db622ca860015f94ff70d779443a86e31f80 (patch)
treed35197c3511cddb557a0fe37e58309246ebcecb7
parent756a8c48b567901d2483e6ea2213c00e5ca47931 (diff)
Make verifyConsistent private
-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++){