I have a matrix (5x5) of boolean values:
matrix = [[False for x in range(5)] for x in range(5)]
matrix[0][3] = True
matrix[2][2] = True
F F F T F
F X F F F
F F T F F
F F F F F
F F F F F
Given an index, I need to find the closer cell which value is True. Where closer means: the cell that can be reached with the lower number of moves, that is the sum between the rows difference and the columns difference must be minimal. So, for example:
row, column = find(row=1, column=1)
# row = 2
# column = 2
What kind of algorithm can I use?