We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7ba6d64 commit 82b8d2bCopy full SHA for 82b8d2b
1 file changed
hackerank/array_1.py
@@ -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