Created
May 26, 2015 04:23
-
-
Save dmattosr/c5b85d7edafa88a4e538 to your computer and use it in GitHub Desktop.
Revisions
-
dmattosr created this gist
May 26, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ 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)