+ 10
Challenge # coding problem #
There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. For example, if N is 4, then there are 5 unique ways: 1, 1, 1, 12, 1, 11, 2, 11, 1, 22, 2 What if, instead of being able to climb 1 or 2 steps at a time, you could climb any number from a set of positive integers X? For example, if X = {1, 3, 5}, you could climb 1, 3, or 5 steps at a time.
7 Respuestas
+ 7
Nice challenge !
I made a code that first gives all combinations (printing them) answering your question with X = {a, b, ..., c}, indefinite number of different jumps, and then calculates the total permutations for each combination (not printing them, too many). Finally it gives the total answer.
https://code.sololearn.com/cCbHULpV1tLj/#py
+ 22
https://www.sololearn.com/Discuss/853148/?ref=app
+ 7
hi
+ 4
I made a variation of it, to be able to print only the result (total number of ways to climb) for a range of integers (1 to 30 for ex) with X = {a, b, c, ...}
https://code.sololearn.com/cxkF8zDbqhTH/#py
+ 4
all variations for 1 or 2 steps at a time.
https://code.sololearn.com/c8AwXCVrmL00/?ref=app
+ 3
Random steps in this one!
https://code.sololearn.com/cVDRZzH5Yi9Z/?ref=app
+ 2
Not your question but gives the answer for any set solution
https://code.sololearn.com/cWPi0YALbaFP/?ref=app