Having a matrix which looks like this
9 9 1 9 9 9 9 1
9 9 1 9 9 9 9 9
9 9 9 9 9 9 9 9
9 9 1 9 9 9 9 9
9 9 9 9 9 1 1 1
9 9 9 9 9 1 9 9
9 9 9 1 9 9 9 9
9 9 1 9 1 9 9 9
I would like to detect for each position in the matrix, if there is at least a value 1
sorrounding the matrix in question such that for element in {2, 2}
i want to check values in {1,1}, {1,2}, {1,3}, {2,1}, {2,3}, {3,1}, {3,2}, {3,3}
and if any position mentioned contains 1, then i store the element in {2,2}
in a seperate variable.
I do not know how to get by this and would like to know if there is any pythonic function or way that can do this?