TOPIC

Wrong Awnser (5%)

Thiago Santos asked 1 year ago

Não tem como estar falhando, já testei muitos casos e todos passam... Por favor, help

def linha_valida(lista):
    for i in xrange(1, 10):
        if i not in lista:
            return False
    return True

def matriz_valida(m):
    for k in range(len(m)):
        if not linha_valida(m[k]):
            return False

    for j in range(len(m[0])):
        linha = []
        for i in range(len(m)):
            linha.append(m[i][j])
        if not linha_valida(linha):
            return False
    return True

m = [[0]*9 for i in range(9)]

n = int(raw_input())

flag = False
for j in range(n):
    for i in xrange(9):
        m[i] = map(int, raw_input().split())

    print 'Instancia %i' % (j+1)
    if matriz_valida(m):
        print 'SIM'
    else:
        print 'NAO'
    if flag:
        print
        print
    else:
        print
    flag = True

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.