How to find the shortest route between (0,0) and (4,4) in a 5x5 matrix, given one horizontal or vertical translation per step
You're asking how to compute the shortest path between two vertices in a graph.  Solution: use an algorithm for computing shortest paths.  In your case, BFS would be a good choice.  There's no need for A*.