... recursion: function


The function we ended up with is show below.

def n_paths(start=1, end=5, jumps=(1, 2)):
    if start > end:
        return 0
    if start == end:
        return 1
    return npaths(start=start + 1, end=end) + npaths(start=start + 2, end=end)

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.