You are viewing a single comment's thread. Return to all comments →
Python 3
def surfaceArea(A): translated_A = list(zip(*A)) front_back = sum(A[0]) + sum(A[H-1]) left_right = sum(translated_A[0]) + sum(translated_A[W-1]) totalArea = 2*H*W + front_back + left_right for h in range(H): for w in range(W): if w != W-1: totalArea += abs(A[h][w+1] - A[h][w]) if h != H-1: totalArea += abs(A[h+1][w] - A[h][w]) return totalArea
Seems like cookies are disabled on this browser, please enable them to open this website
3D Surface Area
You are viewing a single comment's thread. Return to all comments →
Python 3