Given an n
by n
matrix M
, at row i
and column j
, I\'d like to iterate over all the neighboring values in a c
Although I'm not entirely sure what you are trying to do, I'd start like this:
def xxx():
for row in M[i-R:i+R+1]:
for val in row[j-R:j+r+1]:
yield val
I'm not sure how much order you want for your spiral, is it important at all? does it have to be in increasing R order? or perhaps clockwise starting at particular azimuth?
What is the distance measure for R, manhattan? euclidean? something else?