diff options
| author | Simon Tatham <anakin@pobox.com> | 2018-02-26 20:49:14 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2018-02-26 20:49:14 +0000 |
| commit | 2270ee116d2c3ee406cb8c65ac58051664107c42 (patch) | |
| tree | c097c3698288a862090999dd24e209d84be88879 /latin.c | |
| parent | 43b9eb1472d2a82e5369815511a9ae6681a61a08 (diff) | |
| download | puzzles-2270ee116d2c3ee406cb8c65ac58051664107c42.zip puzzles-2270ee116d2c3ee406cb8c65ac58051664107c42.tar.gz puzzles-2270ee116d2c3ee406cb8c65ac58051664107c42.tar.bz2 puzzles-2270ee116d2c3ee406cb8c65ac58051664107c42.tar.xz | |
latin.c: dump every solution found during recursion.
In solver_show_working mode, we were logging all the deductions,
guesswork and backtracking, but not printing out the actual solution
(if any) reached at the end of each branch of the tree.
Diffstat (limited to 'latin.c')
| -rw-r--r-- | latin.c | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -964,13 +964,30 @@ static int latin_solver_top(struct latin_solver *solver, int maxdiff, got_result: #ifdef STANDALONE_SOLVER - if (solver_show_working) - printf("%*s%s found\n", - solver_recurse_depth*4, "", - diff == diff_impossible ? "no solution (impossible)" : - diff == diff_unfinished ? "no solution (unfinished)" : - diff == diff_ambiguous ? "multiple solutions" : - "one solution"); + if (solver_show_working) { + if (diff != diff_impossible && diff != diff_unfinished && + diff != diff_ambiguous) { + int x, y; + + printf("%*sone solution found:\n", solver_recurse_depth*4, ""); + + for (y = 0; y < solver->o; y++) { + printf("%*s", solver_recurse_depth*4+1, ""); + for (x = 0; x < solver->o; x++) { + int val = solver->grid[y*solver->o+x]; + assert(val); + printf(" %s", solver->names[val-1]); + } + printf("\n"); + } + } else { + printf("%*s%s found\n", + solver_recurse_depth*4, "", + diff == diff_impossible ? "no solution (impossible)" : + diff == diff_unfinished ? "no solution (unfinished)" : + "multiple solutions"); + } + } #endif latin_solver_free_scratch(scratch); |