-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.h
66 lines (57 loc) · 1.44 KB
/
grid.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __GRID_H__
#define __GRID_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
typedef enum {
FALSE = 0,
TRUE = 1
} Boolean;
/**
* @brief Create a grid object (square matrix) filled with '0'.
*
* @param size int - size of the grid
* @return char** Pointer to the grid
*/
char** create_grid(int size);
/**
* @brief Free the grid
*
* @param size int - size of the grid
* @param grid char** - pointer to the grid
*/
void free_grid(int size, char** grid);
/**
* @brief Check if the grid contains a char more than once
*
* @param size int - size of the grid
* @param grid char** - pointer to the grid
* @param c char - char to check
* @return Boolean
*/
Boolean contains_char(int size, char** grid, char c);
/**
* @brief Generate a random char
*
* @return char the generated char
*/
char gen_rand_char();
/**
* @brief Check if the grid is correct : if there is no char more than once in each 3*3 sub-grid
*
* @param size int - size of the grid
* @param grid char** - pointer to the grid
* @return char** - pointer to the new grid
*/
char** check_grid(int size, char** grid);
/**
* @brief Fill the grid with random chars following the rules : no char more than once in each 3*3 sub-grid
*
* @param size int - size of the grid
* @param grid char** - pointer to the grid
* @return char** pointer to the new grid
*/
char** fill_grid_algo(int size, char** grid);
#endif