Detect errors in evaluation program
Errors here meaning where a value is filled in but not correct (as opposed to simply missing).
This commit is contained in:
parent
d9c416ffe0
commit
09a9f95740
18
eval.c
18
eval.c
@ -40,7 +40,7 @@ int main(void)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned correct = 0;
|
unsigned solved = 0, errors = 0;
|
||||||
char res[NCELLS], sol[NCELLS];
|
char res[NCELLS], sol[NCELLS];
|
||||||
for (unsigned i = 0; i < NPUZZ; ++i) {
|
for (unsigned i = 0; i < NPUZZ; ++i) {
|
||||||
if (fread(&res, sizeof(char), NCELLS, rfp) != NCELLS) {
|
if (fread(&res, sizeof(char), NCELLS, rfp) != NCELLS) {
|
||||||
@ -52,12 +52,20 @@ int main(void)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(res, sol, NCELLS) == 0)
|
bool allcells = true;
|
||||||
++correct;
|
for (unsigned j = 0; j < NCELLS; ++j) {
|
||||||
|
if (res[j] != sol[j]) {
|
||||||
|
allcells = false;
|
||||||
|
if (res[j] != '0')
|
||||||
|
++errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allcells)
|
||||||
|
++solved;
|
||||||
}
|
}
|
||||||
|
|
||||||
double pc = 1e2 * (double)correct / (double)NPUZZ;
|
double pc = 1e2 * (double)solved / (double)NPUZZ;
|
||||||
printf("%u/%u correct (%.2f%%)\n", correct, NPUZZ, pc);
|
printf("%u/%u (%.2f%%) solved, %u errors\n", solved, NPUZZ, pc, errors);
|
||||||
|
|
||||||
fclose(rfp);
|
fclose(rfp);
|
||||||
fclose(sfp);
|
fclose(sfp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user