Created
May 26, 2015 04:23
-
-
Save dmattosr/c5b85d7edafa88a4e538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check(matriz): | |
def getXY(row, col, matriz): | |
lCol =[matriz[x][col] for x in range(len(matriz)) if x!=row] | |
fila = matriz[row] | |
lFil = [fila[x] for x in range(len(fila)) if x!=col] | |
return lCol+lFil | |
l = range(len(matriz)) | |
for row in l: | |
encontrado = False | |
for col in l: | |
if matriz[row][col] in getXY(row,col,matriz): | |
encontrado = True | |
exit | |
if encontrado: | |
return False | |
return True | |
matriz = [ | |
[4,3,2,1], | |
[2,1,3,4], | |
[1,2,4,3], | |
[3,4,1,2],] | |
print check(matriz) # (True) | |
matriz = [ | |
[4,3,2,1], | |
[2,4,3,4], | |
[1,2,4,3], | |
[3,4,1,2],] | |
print check(matriz) # (False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment