Пример #1
0
def valuacija():
##    s = [[5,3,0,0,7,0,0,0,0],[6,0,0,1,9,5,0,0,0],[0,9,8,0,0,0,0,6,0],[8,0,0,0,6,0,0,0,3],[4,0,0,8,0,3,0,0,1],[7,0,0,0,2,0,0,0,6],[0,6,0,0,0,0,2,8,0],[0,0,0,4,1,9,0,0,5],[0,0,0,0,8,0,0,7,9]]
##    s_r = [[5,3,4,6,7,8,9,1,2],[6,7,2,1,9,5,3,4,8],[1,9,8,3,4,2,5,6,7],[8,5,9,7,6,1,4,2,3],[4,2,6,8,5,3,7,9,1],[7,1,3,9,2,4,8,5,6],[9,6,1,5,3,7,2,8,4],[2,8,7,4,1,9,6,3,5],[3,4,5,2,8,6,1,7,9]]
    s = [[1,2,0,0],[3,0,1,0],[0,1,0,3],[0,0,2,1]]
    s_r = [[1,2,3,4],[3,4,1,2],[2,1,4,3],[4,3,2,1]]
    sud = sudoku(s)
    sudCNF = CNF(sud)
    sudCNFp = sudCNF.poenostavi()
    spremen = sud.var()
    val = {}
    for x in spremen:
        ime = x.vrni_ime()
        i = int(ime[2])
        j = int(ime[4])
        n = int(ime[6])
        if s_r[i][j]==n:
            val[x]= True
        else:
            val[x]= False
    print(sud.izracun(val))
    print(sudCNF.izracun(val))
    print(sudCNFp.izracun(val))
Пример #2
0
def valuacija():
    #h = [[1,1],[1,-1]]
    h = 2
    had = hadamard(h)
    hadCNF = CNF(had)
    hadCNFp = hadCNF.poenostavi()
    spremen = had.var()
    val = {}
    for x in spremen:
        ime = x.vrni_ime()
        i = int(ime[2])
        j = int(ime[4])
        if len(ime) == 9:
            n = int(ime[6]+ime[7])
        else:
            n = int(ime[6])
        if h[i][j]==n:
            val[x]= True
        else:
            val[x]= False
    print(had.izracun(val))
    print(hadCNF.izracun(val))
    print(hadCNFp.izracun(val))