-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2d_arrays.py
More file actions
38 lines (33 loc) · 757 Bytes
/
2d_arrays.py
File metadata and controls
38 lines (33 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/python3
import math
import os
import random
import re
import sys
def hourglass(m,n):
sum = 0
for i in range(m, m+3):
for j in range(n, n+3):
if i != m+1:
sum += arr[i][j]
sum += arr[m+1][n+1]
return sum
if __name__ == '__main__':
arr = []
for _ in range(6):
arr.append(list(map(int, input().rstrip().split())))
rows = len(arr)
cols = len(arr[0])
m = 0
n = 0
sum_arr = []
while m<=rows and n<=cols:
sum = hourglass(m,n)
sum_arr.append(sum)
n += 1
if n > cols-3:
n = 0
m += 1
if m > rows-3:
break
print(max(sum_arr))