diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-10-28 23:16:33 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-10-28 23:16:33 +0200 |
commit | 13b7db622ca860015f94ff70d779443a86e31f80 (patch) | |
tree | d35197c3511cddb557a0fe37e58309246ebcecb7 | |
parent | 756a8c48b567901d2483e6ea2213c00e5ca47931 (diff) |
Make verifyConsistent private
-rw-r--r-- | solve.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -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++){ |