forked from bavishhh/CS101_project_Killer_sudoku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudoku_solver.cpp
68 lines (49 loc) · 1.32 KB
/
sudoku_solver.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
using namespace std;
/* each cage will be assigned a unique id.
* the cells array for each cage will contain the id of the cells belonging to the cage.
* capacity of the cage = no of cells
* cell id = row*10 + col (where row is the row number and col is the column number of the cell)
* each cell will have a unique cell id.
* each cage will have a unique id which equals the index of the cage in the array of cages.
*/
struct cage
{
int sum, capacity;
int cells[];
};
/* If a cell is not assigned any number, then value = 0.
* each cell will have cage_id, i.e. the id of the cage to which the cell belongs
*/
struct cell {
int value;
int cage_id;
};
void solve_sudoku();
void print_board();
int main() {
cell Board[9][9];
//initialize board
for (int i=0; i<9; i++)
for (int j=0; j<9; j++)
Board[i][j].value = 0;
//read input
int no_of_cages;
cin>>no_of_cages;
cage Cage[no_of_cages];
for (int cage_id = 0; cage_id<no_of_cages; cage_id++) {
int cage_sum, no_of_cells;
cin >> no_of_cells >> cage_sum;
Cage[cage_id].sum = cage_sum;
Cage[cage_id].capacity = no_of_cells;
for (int j=0; j<no_of_cells; j++) {
int row, col;
cin >> row >> col;
Cage[cage_id].cells[j] = row*10 + col;
Board[row][col].cage_id = cage_id;
}
}
//solve_sudoku();
//print_board();
return 0;
}