aboutsummaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/sudoku.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/c/sudoku.c b/c/sudoku.c
index a71818b..5982f8f 100644
--- a/c/sudoku.c
+++ b/c/sudoku.c
@@ -12,7 +12,7 @@ bool inBox(int i, int n)
int boxCol = ((i % 9) / 3) * 3;
for(int j = boxRow; j < boxRow + 27; j += 9) {
for(int k = boxCol; k < boxCol + 3; k++){
- if(PUZZLE[j + k] - '0' == n)
+ if(PUZZLE[j + k] - '0' == n && i != j + k)
return true;
}
}
@@ -24,7 +24,7 @@ bool inCol(int i, int n)
{
int col = i % 9;
for(int j = col; j < 81; j += 9) {
- if(PUZZLE[j] - '0' == n)
+ if(PUZZLE[j] - '0' == n && i != j )
return true;
}
return false;
@@ -35,7 +35,7 @@ bool inRow(int i, int n)
{
int row = (i/9) * 9 + 1;
for(int j = row; j < row + 9; j++) {
- if(PUZZLE[j] - '0' == n)
+ if(PUZZLE[j] - '0' == n && i != j)
return true;
}
return false;