diff --git a/sud.c b/sud.c index 4d84a22..f14b20f 100644 --- a/sud.c +++ b/sud.c @@ -54,29 +54,20 @@ enum update_res update(struct sudoku *sud, unsigned r, unsigned c, unsigned val) unsigned tr, tc; const uint16_t clearmask = ~(1 << val); - /* Update possible values of cells in same column. */ - for (tr = 0; tr < NDIGITS; ++tr) { - if (tr == r || DET(sud->cells[tr][c])) - continue; - sud->cells[tr][c] &= clearmask; - } - /* Update possible values of cells in same row. */ - for (tc = 0; tc < NDIGITS; ++tc) { - if (tc == c || DET(sud->cells[r][tc])) - continue; + for (tc = 0; tc < NDIGITS; ++tc) sud->cells[r][tc] &= clearmask; - } + + /* Update possible values of cells in same column. */ + for (tr = 0; tr < NDIGITS; ++tr) + sud->cells[tr][c] &= clearmask; /* Update possible values of cells in same segment. */ const unsigned segr0 = SEGLEN * (r / SEGLEN); const unsigned segc0 = SEGLEN * (c / SEGLEN); for (tr = segr0; tr < segr0 + SEGLEN; ++tr) { - for (tc = segc0; tc < segc0 + SEGLEN; ++tc) { - if ((tr == r && tc == c) || DET(sud->cells[tr][tc])) - continue; + for (tc = segc0; tc < segc0 + SEGLEN; ++tc) sud->cells[tr][tc] &= clearmask; - } } /* Set the cell's value. */