(fname)
return constraints
reads the constraints from file
    (see problems/ folder for examples)
reads the constraints from file
    (see problems/ folder for examples)
reads the constraints from file ( see problems / folder for examples )
def read_constraints(fname):
    """reads the constraints from file
    (see problems/ folder for examples)
    """
    def reader(fname):
        with open(fname, "r") as f:
            for line in f:
                r = line.split()
                for x in r:
                    yield x

    r = reader(fname)
    size = int(next(r))
    constraints = []
    for _ in range(size**2):
        row = []
        for _ in range(size**2):
            w = next(r)
            if w != "X":
                row.append(int(w))
            else:
                row.append(-1)
        constraints.append(row)
    return constraints
def read_constraints ( fname ) : def reader ( fname ) : with open ( fname , "r" ) as f : for line in f : r = line . split ( ) for x in r : yield x r = reader ( fname ) size = int ( next ( r ) ) constraints = [ ] for _ in range ( size ** 2 ) : row = [ ] for _ in range ( size ** 2 ) : w = next ( r ) if w != "X" : row . append ( int ( w ) ) else : row . append ( - 1 ) constraints . append ( row ) return constraints