Sunday, August 27th
A river-crossing frog Given an arrangement of stones, and the ability of a frog to jump k-1 , k , or k+1 distances, determine if the frog can successfully cross the river A variegated golden frog, taken by Charles J. Sharp , distributed by via Wikipedia under the Creative Commons Attribution-Share Alike 4.0 International license. No changes made The dependencies of previous answers to later answers demonstrates overlapping subproblems, and is a candidate for solving with dynamic programming. We first identify our state variables. What does each subproblem consist of? There is the frog's index on the stones array, we are trying to find if the frog can travel from one index to the last index. Also, since the distance a frog can jump depends on the previous jump, the second state variable is the length of the previous jump. With the state variables in mind, we can begin developing the dynamic programming recursive function dp. It accepts 2 variables, the ...