# Last edited on 2021-07-31 11:45:35 by jstolfi def ixdiff(u, v): # Assumes that {u} and {v} are points of some {d}-dimesnional grid. # Returns the number of positions in which they differ. # If either of them is {None}, returns 0. if u == None or v == None: nd = 0 else: nu = len(u); assert len(v) == nu, "incompatible lengths." nd = 0; # Count of differences. for k in range(nu): if u[k] != v[k]: nd += 1 return nd # ----------------------------------------------------------------------