Ask Your Question

Revision history [back]

Instead of storing the best matrix in a variable a, you can store all best matrices in a list (or a set), and flush the list when a better matrix is found. It will look something like (i ):

def xyz(n):
    L = []
    max_det = -infinity
    for A in myfunction(n):
            d = A.det()
            if d == max_det:
                L.append(A)
            elif d>max_det:
                L = [A]
    return L

Also let me suggest you to read about the difference between print and return.

Instead of storing the best matrix in a variable a, you can store all best matrices in a list (or a set), and flush the list when a better matrix is found. found (and update the value of the best determinant). It will look something like (i ):like:

def xyz(n):
    L = []
    max_det = -infinity
    for A in myfunction(n):
            d = A.det()
            if d == max_det:
                L.append(A)
            elif d>max_det:
                L = [A]
                max_det = d
    return L

Also let me suggest you to read about the difference between print and return.

Instead of storing the best matrix in a variable a, you can store all best matrices in a list (or a set), and flush the list when a better matrix is found (and update the value of the best determinant). It will look something like:

def xyz(n):
    L = []
    max_det = -infinity
    for A in myfunction(n):
            d = A.det()
            if d == max_det:
                L.append(A)
            elif d>max_det:
d > max_det:
                L = [A]
                max_det = d
    return L

Also let me suggest you to read about the difference between print and return.