-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
42 lines (40 loc) · 897 Bytes
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include "generator.h"
typedef enum PrgMode {GENERATE, SOLVE} prgMode;
int main (int argc, char *argv[])
{
srand(time(NULL));
// CLI
prgMode mode;
int ROWS, COLS;
switch (*argv[1])
{
case 'g':
mode = GENERATE;
break;
case 's':
mode = SOLVE;
break;
default:
printf(
"Unvalid mode: %s\n"
"Use 'g' for generator or 's' for the solver.\n",
argv[1]
);
exit (1);
break;
}
if (mode == GENERATE)
{
ROWS = atoi(argv[2]);
COLS = atoi(argv[3]);
board *pboard = generator(ROWS, COLS);
printBoard(pboard);
writePuzzleToFile("test/puzzle.txt", pboard, false);
writePuzzleToFile("test/solution.txt", pboard, true);
}
exit (0);
}