From 5eea14c6c3814484d7c74c885e88f48095e93d53 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 22 Dec 2024 20:08:14 +0000 Subject: [PATCH] groupsolver: fix assertion failure. Reproduced via 'groupsolver -v 5i:p1g4' (thanks to Arun Giridhar for the report). The Group-specific solver_hard() function ruled out a bunch of possibilities by deducing various things that couldn't be the group identity, but forgot to set done_something = true, so that it return 0 claiming it hadn't done anything. So latin_solver_top progressed to the next difficulty level and tried recursion. And latin_solver_recurse failed an assertion because it was surprised to find a cell with only one possibility - it expected that the _simple_ deductions would have ruled out any of those, which they would have if solver_hard() had returned >0, because the loop would have reset to the top and tried the easy deductions again after solver_hard() had given them something to work with. --- unfinished/group.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unfinished/group.c b/unfinished/group.c index faffa89..241da0e 100644 --- a/unfinished/group.c +++ b/unfinished/group.c @@ -519,6 +519,7 @@ static int solver_hard(struct latin_solver *solver, void *vctx) } #endif cube(i, j, j+1) = false; + done_something = true; } if (cube(j, i, j+1)) { #ifdef STANDALONE_SOLVER @@ -533,6 +534,7 @@ static int solver_hard(struct latin_solver *solver, void *vctx) } #endif cube(j, i, j+1) = false; + done_something = true; } } }