You need to learn to recognize it. But when it does recursion can turn a complex puzzle into a single function call. In this series of videos we'll explore one such example.
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.