-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vestigium
48 lines (44 loc) · 1.13 KB
/
Vestigium
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
t = int(input())
i = 0
while(i<t):
l = list()
n = int(input())
row_1 = 0
col_1 = 0
for j in range(n):
ele = list(map(int, input().split()))
l.append(ele)
arr = np.array(l).reshape(n,n)
l.clear()
tr = np.trace(arr)
summ = n*(n+1)/2
row = arr.sum(axis = 1)
col = arr.sum(axis = 0)
j = 0
arr_1 = arr.T
arr_row = np.sort(arr, axis = 1)
arr_col = np.sort(arr_1, axis = 1)
for j in range(n):
if(row[j] != summ):
row_1 += 1
else:
temp = arr_row[j][0]
for l in range(1,n):
if(arr_row[j][l] == temp):
row_1 += 1
break
else:
temp = arr_row[j][l]
if(col[j] != summ):
col_1 += 1
else:
temp = arr_col[j][0]
for l in range(1,n):
if(arr_col[j][l] == temp):
col_1 += 1
break
else:
temp = arr_col[j][l]
print("Case #%d:"%(i+1)," ",tr , " ",row_1," ",col_1)
i += 1