code: def find_neighbors(neighbors, coords, I, source_files, f, sides):
      for i, c1 in enumerate(coords):
          me = source_files[I[i]]
          if neighbors[me][sides[0]] != '':
              continue
          for j, c2 in enumerate(coords):
              if f(c1, c2):
                  neigh = source_files[I[j]]
                  neighbors[me][sides[0]] = neigh
                  neighbors[neigh][sides[1]] = me
                  break
      return neighbors