summaryrefslogtreecommitdiff
path: root/update.c
blob: 57c5dda7ad25a24eab69797ef8a4c522e05d3bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
				}
			}
		}
	}
}