[[1,1,1,1],
[0,1,1,1],
[1,1,0,1],
[1,1,1,1]]
If treat them as the locations of 16 points, I want to generate another list N to hold the corresponding value for each point to its nearest 0.
For example:
the nearest 0 point to M[0][0] is M[1][0], so N[0][0]=1;
M[0][1]'s nearest 0 is also at M[1][0], so N[0][1]=2;
but N[0][3]=3 because 0 at M[2][2] is much nearer;
N[1][0]=0 because the distance to itself is 0;
N should be
[[1,2,2,3],
[0,1,1,2],
[1,1,0,1],
[2,2,1,2]]
I am really very new to Python and have no idea how to write the code.
Thanks!
Linda
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor