A
A
Arti-Jack2017-11-24 09:31:31
Programming
Arti-Jack, 2017-11-24 09:31:31

How to calculate the shortest path between two points using a matrix of numbers?

I welcome everyone.
I am writing the so-called Lee Algorithm (aka unary / wave search).
In short, the essence is as follows:
We fill the matrix with numbers, moving in a wave from point A to point B.
Example:
5a17bc18b8938242310690.png5a17bc256fdfe448748519.png5a17bc2e98991768362793.png
In general, I managed to write a function that could fill the matrix in such a way. I used recursive calls for left/right/top/bottom positions and populated the array itself. But the question is: how can I calculate the shortest path now?
PS: I wrote Java code, but it doesn't matter. So you can give an example in any language (but preferably C-like or python).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-11-24
@Arti-Jack

Starting from the end point, you just always go towards the smallest number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question