I am trying to validate if any numbers are duplicates in a 9x9 array however need to exclude all 0 as they are the once I will solve later. I have a 9x9 array and would like to validate if there are any duplicates in the rows and columns however excluding all 0 from the check only numbers from 1 to 9 only. The input array as example would be:
[[1 0 0 7 0 0 0 0 0]
 [0 3 2 0 0 0 0 0 0]
 [0 0 0 6 0 0 0 0 0]
 [0 8 0 0 0 2 0 7 0]
 [5 0 7 0 0 1 0 0 0]
 [0 0 0 0 0 3 6 1 0]
 [7 0 0 0 0 0 2 0 9]
 [0 0 0 0 5 0 0 0 0]
 [3 0 0 0 0 4 0 0 5]]
Here is where I am currently with my code for this:
#Checking Columns
for c in range(9):
    line = (test[:,c])
    print(np.unique(line).shape == line.shape)
#Checking Rows
for r in range(9):
    line = (test[r,:])
    print(np.unique(line).shape == line.shape)
Then I would like to do the exact same for the 3x3 sub arrays in the 9x9 array. Again I need to somehow exclude the 0 from the check. Here is the code I currently have:
for r0 in range(3,9,3):
    for c0 in range(3,9,3):
        test1 = test[:r0,:c0]
        for r in range(3):
            line = (test1[r,:])
            print(np.unique(line).shape == line.shape)
        for c in range(3):
            line = (test1[:,c])
            print(np.unique(line).shape == line.shape)
``
I would truly appreciate assistance in this regard.
 
     
     
    