Skip to content

Instantly share code, notes, and snippets.

@dmattosr
Created May 26, 2015 04:23
Show Gist options
  • Save dmattosr/c5b85d7edafa88a4e538 to your computer and use it in GitHub Desktop.
Save dmattosr/c5b85d7edafa88a4e538 to your computer and use it in GitHub Desktop.

Revisions

  1. dmattosr created this gist May 26, 2015.
    32 changes: 32 additions & 0 deletions check_soduku.py
    Original 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)