shithub: puzzles

Download patch

ref: 35f796542ee5d7e775643f526973aa75f483bf20
parent: 2d9e414ee316b37143954150016e8f4f18358497
author: Simon Tatham <anakin@pobox.com>
date: Tue Oct 24 14:52:12 EDT 2023

Singles: fix error highlighting when grid is disconnected.

The loop that selects one of the disconnected regions (represented as
equivalence classes in a dsf) to _not_ highlight as an error was
failing to call dsf_canonify() to get the canonical element of the
class.

Instead, it was relying on having met the canonical element of the
class first, because it iterates up the array in order, and in the old
dsf implementation, canonical elements were always minimal ones. But
the DSF refactoring made that untrue, so now we have to explicitly
canonify each value we come to.

Thanks to Steffen Bauer for the diagnosis and suggested fix.

--- a/singles.c
+++ b/singles.c
@@ -547,7 +547,7 @@
                 int size = dsf_size(dsf, i);
                 if (largest < size) {
                     largest = size;
-                    canonical = i;
+                    canonical = dsf_canonify(dsf, i);
                 }
             }