<qiyuangong>463_Island_Perimeter_1.java
public int islandPerimeter(int[][] grid) {
        int islands = 0, neighbours = 0;
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[i].length; j++) {
                if (grid[i][j] == 1) {
                    islands++; // count islands
                    if (i < grid.length - 1 && grid[i + 1][j] == 1) neighbours++; // count down neighbours
                    if (j < grid[i].length - 1 && grid[i][j + 1] == 1) neighbours++; // count right neighbours
                }
            }
        }
        return islands * 4 - neighbours * 2;
    }
public int sample_funcname ( int [ ] [ ] var_0 ) {
  int var_2 = 0 , var_3 = 0 ;
  for ( int var_4 = 0 ;
  var_4 < var_0 . length ;
  var_4 ++ ) {
    for ( int var_6 = 0 ;
    var_6 < var_0 [ var_4 ] . length ;
    var_6 ++ ) {
      if ( var_0 [ var_4 ] [ var_6 ] == 1 ) {
        var_2 ++ ;
        if ( var_4 < var_0 . length - 1 && var_0 [ var_4 + 1 ] [ var_6 ] == 1 ) var_3 ++ ;
        if ( var_6 < var_0 [ var_4 ] . length - 1 && var_0 [ var_4 ] [ var_6 + 1 ] == 1 ) var_3 ++ ;
      }
    }
  }
  return var_2 * 4 - var_3 * 2 ;
}
