I have a list and it has (randomly) between 5 and 10 items in it. The first int in the list is always 0 and all others are a random positive number. It could look like this:
0 10 50 45 80 5 35
The goal for the program is to treat the items in the list like spaces, adding to a total sum when you move to the next one. The person starts at 0 and can always either move one space to the right or skip one and land on the next. For example, with the one above I could go from 0 to 10, or 0 to 50 for the first move. I could then do from 50 to 45 or from 50 to 80 and so on.
I want to figure out a recursive algorithm to go through these and find the way to get to the last item with the lowest total sum. Should I be going through every possible combination or is there an easier way to do this? Does it have something to do with checking the value of both possible moves each turn and choosing the lower value?