Skip to content

Commit 82b8d2b

Browse files
committed
hackerank
1 parent 7ba6d64 commit 82b8d2b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

hackerank/array_1.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the hourglassSum function below.
10+
def hourglassSum(arr):
11+
max_sum = -70
12+
for i in range(1,5):
13+
for j in range(1,5):
14+
cur_sum = arr[i][j] + arr[i-1][j-1] + arr[i-1][j] + arr[i-1][j+1] + arr[i+1][j-1] + arr[i+1][j] + arr[i+1][j+1]
15+
max_sum = max(cur_sum, max_sum)
16+
return max_sum
17+
18+
19+
if __name__ == '__main__':
20+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
21+
22+
arr = []
23+
24+
for _ in range(6):
25+
arr.append(list(map(int, input().rstrip().split())))
26+
27+
result = hourglassSum(arr)
28+
29+
fptr.write(str(result) + '\n')
30+
31+
fptr.close()

0 commit comments

Comments
 (0)