-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (34 loc) · 907 Bytes
/
main.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
#include "GridClass.h"
#include <sys/time.h>
bool solveSudoku(GridClass& grid);
int main()
{
GridClass board;
string fname;
bool solved;
cout << "Input file name of puzzle: ";
cin >> fname;
board.loadGrid(fname);
cout << endl << "Puzzle loaded!" << endl;
board.printGrid();
cout << endl << "Solving puzzle... ";
timeval startTime, endTime;
gettimeofday(&startTime, NULL);
solved = solveSudoku(board);
gettimeofday(&endTime, NULL);
if (solved)
{
cout << "[Success!]" << endl;
}
else
{
cout << "[Failed!]" << endl;
cout << "ERROR: Puzzle is not solvable" << endl;
}
double interval = endTime.tv_sec - startTime.tv_sec +
(endTime.tv_usec - startTime.tv_usec) * 1e-6;
cout << "Total time to solve: " << interval << " seconds" << endl;
cout << endl << "Result: " << endl;
board.printGrid();
return 0;
}