You are viewing a single comment's thread. Return to all comments →
def hourglassSum(arr): # Write your code here sum_hourglasses = [] # index_column = 0 index_int = 0 for index_column in range(0, len(arr)-2): """ 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 2 4 4 0 0 0 0 2 0 0 0 0 1 2 4 0 """ for index_int in range(0, len(arr)-2): hour_glass = [ arr[index_column][index_int], arr[index_column][index_int+1], arr[index_column][index_int+2], arr[index_column+1][index_int+1], arr[index_column+2][index_int], arr[index_column+2][index_int+1], arr[index_column+2][index_int+2] ] print(f"{hour_glass=}") sum_hourglasses.append(sum(hour_glass)) return max(sum_hourglasses)
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 →