You are viewing a single comment's thread. Return to all comments →
For Python3:
import math import os import random import re import sys if __name__ == '__main__': arr = [] for _ in range(6): arr.append(list(map(int, input().rstrip().split()))) glasses = [] # Empty array to store all hourglasses for i in range(4): # Iterate over rows for j in range(4): # Iterate over columns curr_sum = 0 first = [arr[i][j], arr[i][j+1], arr[i][j+2]] second = [arr[i+1][j+1]] third = [arr[i+2][j], arr[i+2][j+1], arr[i+2][j+2]] hourglass = [first, second, third] # Declaring current hourglass curr_sum = 0 for k in hourglass: curr_sum += sum(k) glasses.append(curr_sum) # Add total of current hourglass print(max(glasses)) # Return maximum total of all hourglasses array
Seems like cookies are disabled on this browser, please enable them to open this website
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
For Python3: