-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrute_force_board_generation.cpp
51 lines (41 loc) · 1.22 KB
/
brute_force_board_generation.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
#include <iostream>
#include <stdlib.h>
using namespace std;
int board_generation ()
{
//initialization of 9x9 board
int board[9][9];
//initialization of control list (list of valid numbers) we will be making copies of this list and removing any numbers which we cannot use.
int control_list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
//initialization of block (3x3 space in which no digit may be the same) to check for validity
int val_block[3][3];
//initialization of line (9 spaces in which no digit may be the same) to check for validity
int val_line[9];
//nested for loop iterates over all spaces in board...
for (int i = 0; i < 9; i ++)
{
for (int j = 0; j < 9; j++)
{
//...and generates a random number for them
board[i][j] = (rand() % 9) + 1;
}
}
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
cout << "[" << board[i][j] << "]";
//if j is equal to 9, end the line
if (j == 8)
{
cout << "\n" << endl;
cout << "---------------------------\n";
}
}
}
return 0;
}
int main()
{
board_generation();
}