-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsk_bforce.cpp
89 lines (80 loc) · 2.19 KB
/
sk_bforce.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#define _CRT_SECURE_NO_DEPRECATE
//#define ZHOU_OLD
#include <sys/timeb.h>
#include "main.h" // tab0
uint64_t p_cptg[40];
extern ZHOU zhou[50];// , zhou_i, zhou_solve;
extern ZH_GLOBAL zh_g;
extern ZH_GLOBAL2 zh_g2;
extern SGO sgo;
ofstream fout1,fout2;
FINPUT finput;
//========================================
void Go_c10() { // extract valid puzzles from entry
int filter = sgo.bfx[0];
if (!sgo.finput_name) return;
cout << "brute force Go_10 entry " << sgo.finput_name << " input" << endl;
finput.open(sgo.finput_name);
if (!finput.is_open()) {
cerr << "error open file " << sgo.finput_name << endl;
return;
}
char ze[200]; ze[81] = 0;
while (finput.GetPuzzle(ze)) {
int ir = zhou[0].CheckValidityQuick(ze);
if ((!filter) && ir == 1) fout1 << ze << endl;
else if((filter &1) && ir==0)fout1 << ze << endl;
else if ((filter & 2) && ir > 1)fout1 << ze << endl;
}
}
void Go_c11() { // count valid puzzles in entry
if (!sgo.finput_name) return;
cout << "brute force Go_10 entry " << sgo.finput_name << " input" << endl;
finput.open(sgo.finput_name);
if (!finput.is_open()) {
cerr << "error open file " << sgo.finput_name << endl;
return;
}
int loop = sgo.vx[1], mode = 0;
if (loop) {
mode = 1;
cout << "go for n loop=<<loop" << endl;
}
uint64_t cc[3] = { 0,0,0 };
char ze[200]; ze[81] = 0;
switch (mode) {
case 0:
while (finput.GetPuzzle(ze)) {
int ir = zhou[0].CheckValidityQuick(ze);
if (ir < 0 || ir>2) ir = 0;
cc[ir]++;
}
break;
case 1: {
while (finput.GetPuzzle(ze)) {
for (int i = 0; i < loop; i++) {
int ir = zhou[0].CheckValidityQuick(ze);
if (ir < 0 || ir>2) ir = 0;
cc[ir]++;
}
}
}
break;
}
cout << "count " << cc[0] << ";" << cc[1] << ";" << cc[2] << endl;
}
void Go_0() {
// open outputs files 1.txt
if (sgo.foutput_name) {
char zn[200];
strcpy(zn, sgo.foutput_name);
int ll = (int)strlen(zn);
strcpy(&zn[ll], "_file1.txt");
fout1.open(zn);
}
switch (sgo.command) {
case 10: Go_c10(); break; // extract valid puzzles from entry
case 11:Go_c11(); break; // count valid puzzles in entry
}
cerr << "go_0 return" << endl;
}