sudoku Puzzling in Perl #28

implementation

This is only slightly harder than Naked Singles.

## Hidden Singles:
## --------------------------------------------------
GUESSES:
for my $possible ( keys %guesses )
{
   DIMENSION:     # each col, then row, then block
   for my $grouping (
            $sobj->{col  }->[ $curblock->{col}   ],
            $sobj->{row  }->[ $curblock->{row}   ],
            $sobj->{block}->[ $curblock->{block} ],
          )
   {
      GROUP_ITEM: # each item in that grouping/dimension
      for my $group_item ( @$grouping )
      {
         # skip known blocks and this block
         next GROUP_ITEM 
            if $group_item->{square} == $curblock->{square}
            or $group_item->{known};

         next DIMENSION 
            if grep { $_ == $possible } @{ $group_item->{guess} };
      }

      # if we cover the entire dimension without finding another square that
      # can contain that value, then we must be that value
      last ROUND 
         unless mark_known( $sobj, $curblock, $possible );

      next SQUARE;
   }
}
© fishbot