You are viewing a single comment's thread. Return to all comments →
A Python 3 version that doesn't create grid A:
H, W = map(int, input().split()) area = H * W * 2 last_row = [0]*(W+2) for _ in range(H): row = [0, *map(int, input().split()), 0] area += sum(abs(a-b) for a, b in zip(row, row[1:])) area += sum(abs(a-b) for a, b in zip(row, last_row)) last_row = row area += sum(last_row) print(area)
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 →
A Python 3 version that doesn't create grid A: