Backtracking: return possible sequences to climb stairs with jumps python

PHOTO EMBED

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:
            continue
            
        temp = jumps + [i] 
        out += climb(n-i, k, temp)
        
    return out
content_copyCOPY

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

https://app.codesignal.com/interview-practice/task/cAXEnPyzknC5zgd7x/description