-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·53 lines (42 loc) · 1.37 KB
/
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
45
46
47
48
49
50
51
52
53
#include <iostream>
#include "logging/debug.h"
#include "nonogram/Nonogram.h"
using namespace std;
int main(int argc, char *argv[]) {
// Setup configurations.
string file_name;
string log_level = "INFO";
string output = "solution.txt";
for (int i = 1; i < argc; i += 2) {
if (string(argv[i]) == "--log-level") {
log_level = argv[i + 1];
}
if (string(argv[i]) == "--input") {
file_name = argv[i + 1];
}
if (string(argv[i]) == "--output") {
output = argv[i + 1];
}
}
if (file_name.empty() || log_level.empty()) {
throw runtime_error(
"Usage: nonogram --input [FILE_PATH] [--log-level [LOG_LEVEL TRACE|DEBUG|INFO|WARNING|ERROR]] [--output FILE_PATH]");
}
Logger::enabled_level = Logger::get_level_by_string(log_level);
// Load the nonogram.
Nonogram nonogram(file_name);
#if DEBUG_LOGS
Logger(INFO).get() << "Empty Board" << endl;
nonogram.print_board();
#endif // DEBUG_LOGS
// Solve the nonogram.
nonogram.solve();
#if DEBUG_SUMMARY
Logger(ERROR).get() << endl;
Logger(ERROR).get() << "Solution" << endl;
nonogram.print_board(ERROR, Nonogram::color_black, Nonogram::color_empty, Nonogram::color_unknown);
#endif // DEBUG_SUMMARY
// Save the nonogram's solution.
nonogram.save(output);
return 0;
}