So I have an exercise where I should count the ways of climbing a ladder with n amount of steps, with the following restriction: You can only go up by 1, 3 or 5 steps.
The way I could solve the problem was with this code.
(define (climb n)
(cond [(< n 0) 0]
[(<= n 2) 1]
[(= n 3) 2]
[(> n 1) (+ (climb (- n 1)) (climb (- n 3)) (climb (- n 5)))]
)
)
But the problem now is that it is too difficult to get the result, you have to do a lot of calculations. Is it possible to optimize this on the racket? What would the code be like? If I could save the previous 2 results and add it up, it would work better, but I don't know how.