Idea: This is a search graph task. A used this explanation of the algorithm LINK.
In first step you check all possible single jumps from start point. This creates a new "row" of starting positions.
In next step you check all possible single jumps from every start position in the "row".
Sum of found new positions create another row.
You skip if you find a possible jump to the position which was "visited" previously, because there is a shorter or equal path to that position.
You stop when any jump will reach "end position" or you cant find a position to jump anymore.
Code:
Brak komentarzy:
Prześlij komentarz