Commits

Anonymous committed 3c00fb2

Extract _x_indexes from everywhere.

  • Participants
  • Parent commits 95fe574

Comments (0)

Files changed (1)

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

     return (0 .. $BOARD_LEN_LIM);
 }
 
+sub _x_indexes
+{
+    return (0 .. $BOARD_LEN_LIM);
+}
+
 sub _init
 {
     my ($self, $args) = @_;
 
     foreach my $y ($solver->_y_indexes)
     {
-        foreach my $x (0 .. $BOARD_LEN_LIM)
+        foreach my $x ($solver->_x_indexes)
         {
             $sub_ref->($x,$y);
         }
                 }
             }
 
-            my @neighbourhood = (map { [(0) x $BOARD_LEN] } (0 .. $BOARD_LEN_LIM));
+            my @neighbourhood = (map { [(0) x $BOARD_LEN] } ($solver->_y_indexes));
             
             foreach my $true (@true_cells)
             {
 
         $solver->set_verdicts_for_letter_sets(
             \@minor_diagonal_letters,
-            [map { [$_, 4-$_] } (0 .. $BOARD_LEN_LIM)]
+            [map { [$_, 4-$_] } ($solver->_y_indexes)]
         );
     }
 
     {
 
-        foreach my $x (0 .. $BOARD_LEN_LIM)
+        foreach my $x ($solver->_x_indexes)
         {
             $solver->set_verdicts_for_letter_sets(
                 [substr($top_row, $x+1, 1), substr($bottom_row, $x+1, 1),],
             my $row = $rows[$y];
             $solver->set_verdicts_for_letter_sets(
                 [substr($row, 0, 1), substr($row, -1),],
-                [map { [$_,$y] } (0 .. $BOARD_LEN_LIM)],
+                [map { [$_,$y] } $solver->_x_indexes],
             );
 
             my $s = substr($row, 1, -1);
 
     my $tb =
         Text::Table->new(
-            \" | ", map {; "X = $_", (\' | '); } (0 .. $BOARD_LEN_LIM)
+            \" | ", (map {; "X = $_", (\' | '); } $solver->_x_indexes)
         );
 
     foreach my $y ($solver->_y_indexes)
         $tb->add(
             map 
             { $solver->_get_possible_letters_string($_, $y) } 
-            (0 .. $BOARD_LEN_LIM)
+            $solver->_x_indexes
         );
     }