I was working on CodeSignals problem called climbingStaircase and I am one step away from solving it. The embarrasing place where I'm stuck at is building out the resulting variable. It would be a big help, if someone can nudge me in the right direction.
def climbingStaircase(n, k):
def dfs_steps(at_step, taken_steps, stepsPermute): # <<-- I was trying to pass in the
#final result as an argument but it's coming up empty even if I uncomment the line below.
if at_step == 0:
#stepsPermute.append(taken_steps)
print(taken_steps) # <<-- I want to store this in a list of lists
for i in range(1,k+1):
if i <= at_step:
at_step -= i
taken_steps.append(i)
dfs_steps(at_step, taken_steps, stepsPermute) # <<-- Here I tried saving it in stepsPermute but that didn't work.
# I feel like I've confused myself here as well.
taken_steps.pop()
at_step += i
stepsPermute = dfs_steps(n, [], [[]]) # <<-- This is where I want to gather every resulting list.
return stepsPermute
climbingStaircase(7, 3)Thanks for giving your time.