This question is best asked by example. Suppose that I have a 2D array
[[1, 1, 2], [1, 2, 1], [1, 1, 1]]
I need a function that could take