Optimization in matrix ?

I have matrix[4][4] for example:
' *  '
'  * '
'     '
'     '
enter in matrix(for example) with coordinates [0][0]
and exit [0][3].
How to find optimizing way from enter to exit ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What do you wish to optimize?
What you want is a maze-solving solution, not a matrix-solving solution.  A matrix is just a way of storing/representing a maze (such as a minefield).

The solution will depend on whether you allow wrapping, etc.  We need the rules.
if there are no blocks between
the enter and exit point:
I would calculate each step the Length
from the immidiate neighbour points to me to the exit point.
I would choose the shortest length each time.

If there might be block, it isn't as simple.
one should can use Backtracking
to find the path.

heres a recurse "rough" definition:

f(location, matrix)
  if you are at the enter pos and have
  nowhere to go - quit, failer.
  if you are in the Exit point -
  quit, Success.
  if you don't have any place to go
  (all is block (except the from where
  you came)) mark the place as DeadEnd.
  <do nothing, the recurse will pop you
  to the prev. position>
  call f(Location, matrix) for all
  free places that aren't blocked or a dead end.

Any questions ....


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.