diff --git a/data_structures/arrays/2d_array_ds.py b/data_structures/arrays/2d_array_ds.py new file mode 100644 index 0000000..4e58982 --- /dev/null +++ b/data_structures/arrays/2d_array_ds.py @@ -0,0 +1,37 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the hourglassSum function below. +def hourglassSum(arr): + lis=[-999]*16 + c=0 + for i in range(0,4): + for j in range(0,4): + lis[c]= sum(arr[i][j:j+3]) + sum(arr[i+2][j:j+3]) + c+=1 + c=0 + for i in range(1,5): + for j in range(1,5): + lis[c]+=arr[i][j] + c+=1 + return max(lis) + + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + arr = [] + + for _ in range(6): + arr.append(list(map(int, input().rstrip().split()))) + + result = hourglassSum(arr) + + fptr.write(str(result) + '\n') + + fptr.close() diff --git a/data_structures/arrays/Array_ds.py b/data_structures/arrays/Array_ds.py new file mode 100644 index 0000000..b601ce9 --- /dev/null +++ b/data_structures/arrays/Array_ds.py @@ -0,0 +1,27 @@ + +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# Complete the reverseArray function below. +def reverseArray(a): + a.reverse() + return a + +if __name__ == '__main__': + fptr = open(os.environ['OUTPUT_PATH'], 'w') + + arr_count = int(input()) + + arr = list(map(int, input().rstrip().split())) + + res = reverseArray(arr) + + fptr.write(' '.join(map(str, res))) + fptr.write('\n') + + fptr.close()