'Staircase problem in Python - How to list all the ways to climb a staircase of N steps

I have the following question related to the staircase problem: There is a staircase with N steps, and you can climb 1 or 3 steps a time. Write a function climbcombination(N) which return the all the combination of steps to climb the staircase.

Expected output:

climbcombination(4) return ['1111', '13', '31']

I have difficulties in solving this problem because the function can only take one argument. Any help is really appreciated.

This is the function that I have written for counting the total number of combination to climb up the ladder

def climbNo(N):
if N == 1:
    return 1
if N == 2:
    return 1
if N == 3:
    return 2
else:
    return climbNo(N-1) + climbNo(N-3)

In attempting to print all the combination to climb up the stairs. This is what I have written.

def climbcombination(N):
result = []
if N == 1:
    step = '1'
    result.append(step)
if N == 2:

May I know how can I use the (if N==1 statement) to let the function to return ['11'] when N = 2? Thanks a lot!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source