Skip to content

Instantly share code, notes, and snippets.

@m4hi2
Created September 28, 2017 22:21
Show Gist options
  • Save m4hi2/9a675b32d6319c66b96b9b60be4eb22c to your computer and use it in GitHub Desktop.
Save m4hi2/9a675b32d6319c66b96b9b60be4eb22c to your computer and use it in GitHub Desktop.
def sum(array):
sum = 0
for i in array:
sum += i
return sum
class Matrix():
def __init__(self):
self.row = 0
self.array = [[0]*6 for i in range(6)]
def add_value(self, line):
columnCounter = 0
converted_into_integers = [*map(int, line.split())]
for i in converted_into_integers:
self.array[self.row][columnCounter] = i
columnCounter += 1
self.row += 1
def hour_glass_extraction(self):
start = [0, 0]
hour_glasses = []
for y in range(4):
for i in range(4):
inner_glasses = []
for j in range(start[1], start[1]+3):
inner_glasses.append(self.array[start[0]][j])
inner_glasses.append(self.array[start[0] + 1][start[1] + 1])
for x in range(start[1], start[1]+3):
inner_glasses.append(self.array[start[0] + 2][x])
hour_glasses.append(inner_glasses)
start[1] = start[1] + 1
start[0] = start[0] + 1
start[1] = 0
return hour_glasses
d2 = Matrix()
for x in range(6):
d2.add_value(input())
hg =d2.hour_glass_extraction()
sum_of_hour_glasses = [sum(i) for i in hg]
mx = max(sum_of_hour_glasses)
print(mx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment