code: static int applyMaskPenaltyRule2(ByteMatrix matrix) {
      int penalty = 0;
      byte[][] array = matrix.getArray();
      int width = matrix.getWidth();
      int height = matrix.getHeight();
      for (int y = 0; y < height - 1; y++) {
        byte[] arrayY = array[y];
        for (int x = 0; x < width - 1; x++) {
          int value = arrayY[x];
          if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
            penalty++;
          }
        }
      }
      return N2 * penalty;
    }
docs: Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
  penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a
  penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.