FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonprogram/diagonaldifference at master · seeditsolution/pythonprogram · GitHub
seeditsolution
pythonprogram
Repository navigation
Code
Issues
Pull requests
623
(623)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonprogram
/
diagonaldifference
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (16 loc) · 427 Bytes
Breadcrumbs
pythonprogram
/
diagonaldifference
Copy path
File metadata and controls
22 lines (16 loc) · 427 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def diagonalDifference(arr) #function accepting a 2d array
sum1=0
sum2=0
res=0
for i in range(0,len(arr)):
sum1=sum1+arr[i][i]
sum2=sum2+arr[i][(len(arr)-1)-i]
res=sum1-sum2
return abs(res)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip) #size
arr = []
for _ in range(n):
arr.append(list(map(int, input().rstrip().split())))
print( diagonalDifference(arr))
Back
|
FazBrowse Home
|
New Git URL