chiark / gitweb /
Don't fail an assertion when setting up the provided clues at the
authorSimon Tatham <anakin@pobox.com>
Sun, 29 Jul 2012 21:29:26 +0000 (21:29 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 29 Jul 2012 21:29:26 +0000 (21:29 +0000)
start of the solver, if they contradict each other. (Could trigger on
user-provided grids.)

[originally from svn r9594]

solo.c

diff --git a/solo.c b/solo.c
index 70621948c3ed3f5bec3c921d8777e51608663537..43abc1f8e7213cad033b848556f1f50e9d5f8164 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -1773,9 +1773,16 @@ static void solver(int cr, struct block_structure *blocks,
      * Place all the clue numbers we are given.
      */
     for (x = 0; x < cr; x++)
-       for (y = 0; y < cr; y++)
-           if (grid[y*cr+x])
+       for (y = 0; y < cr; y++) {
+            int n = grid[y*cr+x];
+           if (n) {
+                if (!cube(x,y,n)) {
+                    diff = DIFF_IMPOSSIBLE;
+                    goto got_result;
+                }
                solver_place(usage, x, y, grid[y*cr+x]);
+            }
+        }
 
     /*
      * Now loop over the grid repeatedly trying all permitted modes