-
Notifications
You must be signed in to change notification settings - Fork 1
/
Solver.h
50 lines (42 loc) · 1.77 KB
/
Solver.h
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
/*
* Solver.h
*
* Created on: Dec 11, 2018
* Author: eyal & nadin
*/
#ifndef SOLVER_H_
#define SOLVER_H_
/*void solver_solveBoard(int** mat, int size, int** matNew);*/
/*solver_randomizeBacktracking
* Input: int** matrixSolve.
* return: bool true or false.
* return false if matrix is not solvable. otherwise true.
* the function receives matrix with the value of 0 in each cell.
* for each cell the function chooses randomly a value from the legal values and place it.
* the function continue to check all options for numbers to fill until all matrix is filled.
* if after checking all options for one cell no value solve the board it returns false.
*/
bool solver_randomizeBacktracking(int** matrixSolve);
/*solver_is_legalValue
* Input:
* int** matrixPlay: pointer to the matrix the user play with.
* int x: value of raw of a chosen cell
* int y: value of columns of a chosen cell
* int checked_value: the value which we are checking
* return: bool true or false.
* the function check whether the checked value can be placed in cell[x][y].
* it can be placed if the checked value is not in the same raw,column and block.
* if not it return false.
*/
bool solver_is_legalValue(int **matrixPlay, int x, int y, int checked_value);
/*solver_determenistic_algo
* Input:
* int** matrixPlay: current matrix that the user play with
* int** matrixSolve: last updated solved solution to the matrix.
* return: bool true/false
* true if the matrix is solvable. in each empty cell the function try to put legal values from 1-9.
* if after trying all options no solution found, it returns false.
* otherwise if in all empty cells valid number have been placed, it returns true.
*/
bool solver_determenistic_algo(int **matrixPlay,int **matrixSolve);
#endif