In my assignment I have a MxN grid
e.g.
M = 5, N = 8
KKKK....
.###...X
.XX#...X
...#....
........
K - start point, X - finish point, # - obstacle
I need to find the smallest number of moves to carry packages from start points to finish points. We can only carry 1 package at a time and we can't move diagonally.
The answer for this example is 20.
My suggestion would be to implement A* algorithm and launch it for every possibility (calculate the smallest number of moves from each of the start points to each of the end points) and the pick the smallest one, considering the fact that 1 package covers 1 end point.
Is there a better way to implement that?