diff --git a/eval.c b/eval.c index fcad8f1..19cdd48 100644 --- a/eval.c +++ b/eval.c @@ -40,7 +40,7 @@ int main(void) return EXIT_FAILURE; } - unsigned correct = 0; + unsigned solved = 0, errors = 0; char res[NCELLS], sol[NCELLS]; for (unsigned i = 0; i < NPUZZ; ++i) { if (fread(&res, sizeof(char), NCELLS, rfp) != NCELLS) { @@ -52,12 +52,20 @@ int main(void) return EXIT_FAILURE; } - if (memcmp(res, sol, NCELLS) == 0) - ++correct; + bool allcells = true; + 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; - printf("%u/%u correct (%.2f%%)\n", correct, NPUZZ, pc); + double pc = 1e2 * (double)solved / (double)NPUZZ; + printf("%u/%u (%.2f%%) solved, %u errors\n", solved, NPUZZ, pc, errors); fclose(rfp); fclose(sfp);