from sympy.utilities.iterables import multiset_permutations def findCoordAround(center, nbAround): find = [] for i in range(len(center)): find = getNCoordDiff(center,find,i,nbAround) return find def getNCoordDiff(center,find,nbDiffValue, nbAround): coord = [] if (-nbAround+nbAround >= nbDiffValue): return find for i in range(nbDiffValue): coord.append(-nbAround+i) while True: modified = False cursor = len(coord)-1 while(not modified): if (cursor<0): return find if (coord[cursor]+len(coord)-1-cursor