I'm assuming that this code is for Vestigium. There are 2 problems I can 
see so far:

1. In `main()` function, `for _ in range(1,int(input())+1)` is for each 
test case, and that is good. What is not good is `for i in 
range(1,order+1)`. Why are you iterating through each `order`, and creating 
a matrix, calculate, and print *for each order*? You should do that once 
for each test case.
2. In CreateMatrix function, `a.append(int(input()))` would throw error. 
The rows are given to you as a whole as space-separated numbers and cannot 
be converted to `int`. Note that when the input gives you the matrix, *each 
input is one row*, so you should not iterate through each column in the row 
above.


On Monday, April 6, 2020 at 5:45:53 PM UTC-7, Laxman Negi wrote:
>
> *Language: Python 3*
>
> Hello, 
>
> def sumtracing(mx,n):
>         s=0
>         for i in range(n):
>             s+=mx[i][i]
>         return s
>
> def countIdenticalRows(mat): 
>     count = 0
>     for i in range(len(mat)): 
>         hs=dict() 
>   
>         #Traverse the row 
>         for j in range(len(mat[i])): 
>   
>             #Add all the values of the row in HashSet 
>             hs[mat[i][j]]=1
>           
>   
>         #Check if size of HashSet = 1 
>         if (len(hs)== 1): 
>             count+=1
>       
>   
>     return count
>
> def countIdenticalColumn(mat): 
>     count = 0
>     for i in range(len(mat)): 
>         hs=dict() 
>   
>         #Traverse the row 
>         for j in range(len(mat[i])): 
>   
>             #Add all the values of the row in HashSet 
>             hs[mat[j][i]]=1
>           
>   
>         #Check if size of HashSet = 1 
>         if (len(hs)== 1): 
>             count+=1
>       
>   
>     return count
>
> def CreateMartix(R,C):
>     matrix = [] 
>     # For user input 
>     for i in range(R):          # A for loop for row entries 
>         a =[] 
>         for j in range(C):      # A for loop for column entries 
>             a.append(int(input())) 
>         matrix.append(a) 
>   
>     return matrix
>
> def main():
>         for _ in range(1,int(input())+1):
>             order = int(input().strip())
>             
>             trace= 0;
>             No_row = 0;
>             No_Column = 0;
>             flag=False
>             for i in range(1,order+1):
>                 x=CreateMartix(order,order)
>                 trace =sumtracing(x,order)
>                 No_row = countIdenticalRows(x)
>                 No_Column = countIdenticalColumn(x)
>                 
>                 print("Case " + str(_) + "# ",end="")
>                 print(trace,No_row,No_Column,sep=" ")
>
> main()
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/3e3b95a9-2b4a-41f5-b935-780541be75dd%40googlegroups.com.

Reply via email to