aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Brattlof <hello@bryanbrattlof.com>2020-08-08 19:26:10 -0400
committerBryan Brattlof <hello@bryanbrattlof.com>2020-08-08 19:26:10 -0400
commitae541490bdd2dc592f21c2fbc5bdd196dddfafd3 (patch)
tree7866ca9f68ddfa44f06d147d955499406e1275b9
parentbbbe3fc8d2b94689979529e5ce4d38075e296f7e (diff)
downloadsudoku-ae541490bdd2dc592f21c2fbc5bdd196dddfafd3.tar.gz
sudoku-ae541490bdd2dc592f21c2fbc5bdd196dddfafd3.tar.bz2
c: fix bug in inRow
'row' was calulating the row ther given index 'i' however we didn't convert that into what the starting index should be for that row eg: row = 3 -> start index 'j' = 18
-rw-r--r--c/sudoku.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/c/sudoku.c b/c/sudoku.c
index f2af05f..a71818b 100644
--- a/c/sudoku.c
+++ b/c/sudoku.c
@@ -33,8 +33,8 @@ bool inCol(int i, int n)
bool inRow(int i, int n)
{
- int row = i/9;
- for(int j = row; j/9 <= row; j++) {
+ int row = (i/9) * 9 + 1;
+ for(int j = row; j < row + 9; j++) {
if(PUZZLE[j] - '0' == n)
return true;
}