Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed cfe8f2a

More refactoring.

  • Participants
  • Parent commits a2caddf

Comments (0)

Files changed (1)

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

 
     my @rows = split(/\n/, $layout_string);
 
+    my $top_row = shift(@rows);;
+    my $bottom_row = pop(@rows);
+
     {
         my %count_letters = (map { $_ => 0 } @letters);
         foreach my $letter ($layout_string =~ m{($letter_re)}g)
     {
         my @major_diagonal_letters;
 
-        $rows[0] =~ m{\A($letter_re)};
+        $top_row =~ m{\A($letter_re)};
 
         push @major_diagonal_letters, $1;
 
-        $rows[-1] =~ m{($letter_re)\z};
+        $bottom_row =~ m{($letter_re)\z};
 
         push @major_diagonal_letters, $1;
 
     {
         my @minor_diagonal_letters;
 
-        $rows[0] =~ m{($letter_re)\z};
+        $top_row =~ m{($letter_re)\z};
 
         push @minor_diagonal_letters, $1;
 
-        $rows[-1] =~ m{\A($letter_re)};
+        $bottom_row =~ m{\A($letter_re)};
 
         push @minor_diagonal_letters, $1;
 
     }
 
     {
-        my $top_row = $rows[0];
-        my $bottom_row = $rows[-1];
 
         foreach my $x (0 .. $BOARD_LEN_LIM)
         {
         my ($clue_x, $clue_y, $clue_letter);
         foreach my $y (0 .. $BOARD_LEN_LIM)
         {
-            my $row = $rows[$y+1];
+            my $row = $rows[$y];
             $solver->set_verdicts_for_letter_sets(
                 [substr($row, 0, 1), substr($row, -1),],
                 [map { [$_,$y] } (0 .. $BOARD_LEN_LIM)],