You are viewing a single comment's thread. Return to all comments →
As array indices also start from zero, it would be convenient to let range function start from 0 (which it does by default):
print(max([sum(arr[i][j:j+3] + [arr[i+1][j+1]] + arr[i+2][j:j+3]) for i in range(4) for j in range(4)]))
Seems like cookies are disabled on this browser, please enable them to open this website
2D Array - DS
You are viewing a single comment's thread. Return to all comments →
As array indices also start from zero, it would be convenient to let range function start from 0 (which it does by default):
print(max([sum(arr[i][j:j+3] + [arr[i+1][j+1]] + arr[i+2][j:j+3]) for i in range(4) for j in range(4)]))