<doocs>0463.Island Perimeter_1.py
def islandPerimeter( grid: List[List[int]]) -> int:
    m, n = len(grid), len(grid[0])
    ans = 0
    for i in range(m):
        for j in range(n):
            if grid[i][j] == 1:
                ans += 4
                if i < m - 1 and grid[i + 1][j] == 1:
                    ans -= 2
                if j < n - 1 and grid[i][j + 1] == 1:
                    ans -= 2
    return ans
def sample_funcname ( var_0 : List [ List [ int ] ] ) -> int :
    var_4 , var_6 = len ( var_0 ) , len ( var_0 [ 0 ] )
    var_7 = 0
    for var_9 in range ( var_4 ) :
        for var_10 in range ( var_6 ) :
            if var_0 [ var_9 ] [ var_10 ] == 1 :
                var_7 += 4
                if var_9 < var_4 - 1 and var_0 [ var_9 + 1 ] [ var_10 ] == 1 :
                    var_7 -= 2
                if var_10 < var_6 - 1 and var_0 [ var_9 ] [ var_10 + 1 ] == 1 :
                    var_7 -= 2
    return var_7
