jeudi 8 avril 2021

What is the logic needed to find all possible solutions to this recursion puzzle?

The puzzle uses an array of positive integers. The objective is to find a path from index zero to the last index in the array. At each step we need to know the distance to be traveled and the direction. Each entry in the array is a number indicating the distance to be traveled on this particular leg of the path. The player (your program) needs to decide the direction (if the move should be made to the right or to the left).

Example, if You have an Integer Array [3,6,4,1,3,4,2,5,3,0]

1.Move right to index 0, 2.Move right 3 spaces based on number @ index 0 3.Move left 1 space based on number @ index 4 4.Move right 4 spaces based on number @ index 2. 5.Move right 2 spaces based on number @ index 6 6.Move left 3 spaces based on number @ index 8 7.Move right 4 spaces based on number @ index 5 8.Reached end of list.

Link to image example.




Aucun commentaire:

Enregistrer un commentaire