summaryrefslogtreecommitdiff
path: root/update.c
diff options
context:
space:
mode:
Diffstat (limited to 'update.c')
-rw-r--r--update.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/update.c b/update.c
new file mode 100644
index 0000000..57c5dda
--- /dev/null
+++ b/update.c
@@ -0,0 +1,34 @@
+#include "cell.h"
+#include "debug.h"
+
+/*
+ * update_not_row_col
+ *
+ * For each unsolved cell on the board, update its list of values that it
+ * cannot be based on the solved cells in the same row or the same column
+ * Does not attempt to solve cells
+ */
+void update_not_row_col(struct cell (*b)[9][9])
+{
+ int x = 0;
+ int y = 0;
+ int i = 0;
+ int val = 0;
+
+ for (y = 0; y < 9; y++)
+ {
+ for (x = 0; x < 9; x++)
+ {
+ val = (*b)[x][y].val;
+ if (val != 0)
+ {
+ DEBUG_LOG("Update: (%d,%d) has value %d\n", x, y, val);
+ for (i = 0; i < 9; i++)
+ {
+ (*b)[i][y].not[val - 1] = 1;
+ (*b)[x][i].not[val - 1] = 1;
+ }
+ }
+ }
+ }
+}