Patch from Ben Hutchings to fix an error-checking goof: Keen
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 16 May 2010 06:58:09 +0000 (06:58 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 16 May 2010 06:58:09 +0000 (06:58 +0000)
division clues were failing to light up as erroneous if the quotient
of the numbers in them came out right under rounded-down C integer
division (e.g. 2 and 5 would be accepted for a 2/ clue). Apparently
I copied the code that invents clues in the generator straight into
the solution checker, without remembering that the generator was
allowed to do it that way because exact divisibility had been
checked elsewhere.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@8951 cda61777-01e9-0310-a592-d414129be87e

keen.c

diff --git a/keen.c b/keen.c
index fe41496..bec5055 100644 (file)
--- a/keen.c
+++ b/keen.c
@@ -1450,11 +1450,12 @@ static int check_errors(game_state *state, long *errors)
                break;
              case C_DIV:
                {
-                   int d1 = cluevals[j], d2 = state->grid[i];
-                   if (d1 == 0 || d2 == 0)
+                   int d1 = min(cluevals[j], state->grid[i]);
+                   int d2 = max(cluevals[j], state->grid[i]);
+                   if (d1 == 0 || d2 % d1 != 0)
                        cluevals[j] = 0;
                    else
-                       cluevals[j] = d2/d1 + d1/d2;/* one of them is 0 :-) */
+                       cluevals[j] = d2 / d1;
                }
                break;
            }