Backtracking: return possible sequences to climb stairs with jumps python


Tue Aug 09 2022 21:41:13 GMT+0000 (Coordinated Universal Time)

Saved by @bryantirawan #python #depth #first #search #recursive #codesignal #climb

def solution(n, k):
    return climb(n, k, [])
def climb(n, k, jumps):
    if n == 0:
        return [jumps]
    out = []
    for i in range(1, k+1):
        if i > n:
        temp = jumps + [i] 
        out += climb(n-i, k, temp)
    return out

Hard to understand decision tree. Try python tutoring it. Decision tree: If k was 3 then you have 3 branches each step instead of just 2