Anonymous avatar Anonymous committed ea2a43b

Add more.

Comments (0)

Files changed (1)

abc-path/perl-quick-and-dirty/abc-path-solver.pl

     return $self->{_moves};
 }
 
+sub _error {
+    my $self = shift;
+
+    if (@_) {
+        $self->{_error} = shift;
+    }
+
+    return $self->{_error};
+}
+
+
 sub _inc_changed {
     my ($self) = @_;
 
 
     foreach my $y ($self->_y_indexes)
     {
+        if ($self->_error())
+        {
+            return;
+        }
         foreach my $x ($self->_x_indexes)
         {
+            if ($self->_error())
+            {
+                return;
+            }
             $sub_ref->($x,$y);
         }
     }
             }
         });
 
-        if (@true_cells == 1)
+        if (! @true_cells)
+        {
+            $self->_error(['letter', $letter]);
+            return;
+        }
+        elsif (@true_cells == 1)
         {
             my $xy = $true_cells[0];
             if ($self->get_verdict($letter, @$xy) ==
 
         my $letters_aref = $self->_get_possible_letter_indexes($x, $y);
 
-        if (@$letters_aref == 1)
+        if (! @$letters_aref)
+        {
+            $self->_error(['cell', [$x, $y]]);
+            return;
+        }
+        elsif (@$letters_aref == 1)
         {
             my $letter = $letters_aref->[0];
 
 
     while (my $iter_changed = $self->_inference_iteration())
     {
+        if ($self->_error())
+        {
+            return;
+        }
         $num_changed += $iter_changed;
     }
 
 
     $self->_neighbourhood_and_individuality_inferring;
 
+    if ($self->_error)
+    {
+        return $self->_error;
+    }
+
+    my @min_coords;
+    my @min_options;
+
+    $self->xy_loop(sub {
+        my ($x, $y) = @_;
+
+        my $letters_aref = $self->_get_possible_letter_indexes($x, $y);
+
+        if (! @$letters_aref)
+        {
+            $self->_error(['cell', [$x, $y]]);
+        }
+        elsif (@$letters_aref > 1)
+        {
+            if ((!@min_coords) or (@$letters_aref < @min_options))
+            {
+                @min_options = @$letters_aref;
+                @min_coords = ($x,$y);
+            }
+        }
+
+        return;
+    });
+
+    if ($self->_error)
+    {
+        return $self->_error;
+    }
+
+    if (@min_coords)
+    {
+        # We have at least one multiple rank cell. Let's recurse there:
+    }
+
     return;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.