i don't know if this is the most efficient way, but one of the easy ways of doing this, are to write a program that would go through all the possibilities, then store them in an array, along with the number of moves it took (probably want to make a class for this). then, do a check to see which one is the smallest.
here's an example of the data members, but i won't write all the code for u:
class route {
private:
int moves;
coords *routeHead; //linked list of the directions it took
}
class coords {
private:
int x;
int y;
}
to go through each possibility, have a recursive function that checks to see if it can go in each direction, if it can, it calls itself. base case is it reaches the end of the maze, or it can't go anywhere but back. while it does this, it records the data into the class.
----------------------------
http://aeonofdarkness.com