We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 28f0cb0 commit f6bc09aCopy full SHA for f6bc09a
HackerRank-Diagonal Difference/Diagonal_Difference.py
@@ -0,0 +1,35 @@
1
+#!/bin/python3
2
+
3
+import math
4
+import os
5
+import random
6
+import re
7
+import sys
8
9
+# Complete the diagonalDifference function below.
10
+def diagonalDifference(arr):
11
+ prim =0
12
+ sec=0
13
+ length = len(arr[0])
14
+ i=0
15
+ for count in range(length):
16
+ prim += arr[count][count]
17
+ sec += arr[count][(length-count-1)]
18
+ return abs(prim-sec)
19
20
21
+if __name__ == '__main__':
22
+ fptr = open(os.environ['OUTPUT_PATH'], 'w')
23
24
+ n = int(input())
25
26
+ arr = []
27
28
+ for _ in range(n):
29
+ arr.append(list(map(int, input().rstrip().split())))
30
31
+ result = diagonalDifference(arr)
32
33
+ fptr.write(str(result) + '\n')
34
35
+ fptr.close()
0 commit comments