From 3ea0f9396c7dd04ad03b5187782518837c36d470 Mon Sep 17 00:00:00 2001 From: IndraAdhikary <43936212+IndraAdhikary@users.noreply.github.com> Date: Fri, 25 Oct 2019 15:41:25 +0530 Subject: [PATCH 1/2] Create Array_ds.py Arrays ds in python solution --- data_structures/arrays/Array_ds.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 data_structures/arrays/Array_ds.py 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() From 50effd6756d08f704348ec1cc8a91a56b545bd89 Mon Sep 17 00:00:00 2001 From: IndraAdhikary <43936212+IndraAdhikary@users.noreply.github.com> Date: Fri, 25 Oct 2019 15:43:13 +0530 Subject: [PATCH 2/2] Create 2d_array_ds.py Python soltion for 2d array ds problem --- data_structures/arrays/2d_array_ds.py | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 data_structures/arrays/2d_array_ds.py 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()