... 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 sum([n_paths(start=start + j, end=end) for j in jumps])

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.