Find the number of ways to climb a stairway Challenge:
Find the number of ways to climb some stairs with n steps and with some limitations. You should be able to run the tests below on TIO https://tio.run/ without timing out. – 60 seconds. (Typically a fraction of a second is well within reach for most languages if a good optimizing strategy is applied).
The input is a list of positive numbers:

the first number in the input is the total number of steps in the stairway
the rest of the input is the different number of steps you are allowed to climb at once, but you're only allowed to use n steps a maximum n times if n&gt;1. So if 2 is allowed you're only allowed to take 2 steps a maximum of 2 times. And 3 steps maximum 3 times and so on for all n&gt;1. So if 1 is allowed, you can take 1 step as many times as you like.
you should not &quot;overstep&quot;, with a stairway of 5 steps and only 2 steps at once are allowed, there is no way to climb it (output 0)

Allowed assumptions: all input numbers are positive integers, at least 1 (0, negative and fractional numbers need no special handling). The list of allowed steps are unique numbers and ordered if it helps. Also the size of the stairs can be the last number or a separate part of the input if that's helpful to your implementation (&quot;reorganizing&quot; input don't need to be a part of the problem)
Output:

a number which is the number of ways to climb the stairs

Examples:

Input: 3,1      Output: 1 (as there is only one way when you're only allowed one step at a time)
Input: 3,1,2    Output: 3 (since you can climb in three ways: 1+1+1 or 1+2 or 2+1)
Input: 3,4      Output: 0 (you should always end at the top, you cannot take 4 steps since the stairs only has 3)
Input: 4,1,2,3  Output: 7 (1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 3+1, 1+3)
Input: 6,2      Output: 0 (since you're not allowed to take 2 steps 3 times)
Input: 6,2,1    Output: 12 (2+2+1+1,  2+1+2+1,  2+1+1+2,  2+1+1+1+1,  1+2+2+1,  1+2+1+2,  1+2+1+1+1,  1+1+2+2,  1+1+2+1+1,  1+1+1+2+1,  1+1+1+1+2,  1+1+1+1+1+1. But 2+2+2 isn't allowed)
Input: 99,99,1  Output: 2  (99 or 1+1+1+1+...99 times)

More tests:
2,1        → 1
10,1       → 1
3,1,2      → 3
3,4        → 0
3,2        → 0
4,1,2      → 5
4,1,2,3    → 7
6,2        → 0
6,2,1      → 12
7,1,2      → 17
5,1,2,3    → 13
15,1,2,7   → 266
39,3,2,7   → 301
99,11,3,2  → 1981
JavaScript (ES6), 71 bytes
Expects (list)(n).

(a,t=0)=&gt;g=n=&gt;n&gt;0?a.map(x=&gt;--g[(g[x]=-~g[x])+~x|x&lt;2&amp;&amp;g(n-x),x])|t:t+=!n

Try it online!
Commented
(a, t = 0) =&gt;           // a[] = input list, t = output
g = n =&gt;                // g is a recursive function taking the number of steps n
  n &gt; 0 ?               // if n is positive:
    a.map(x =&gt;          //   for each value x in a[]:
      --g[              //     decrement g[x] afterwards
        (g[x] = -~g[x]) //       increment g[x]
        + ~x |          //       if g[x] is not equal to x + 1
        x &lt; 2 &amp;&amp;        //       or x = 1:
          g(n - x),     //         do a recursive call with n - x
        x               //       actual index to update g[x]
      ]                 //     end of entry update: this is guaranteed to be 0 on
                        //     the first iteration; therefore, .map() is coerced to
                        //     0 by the the bitwise OR even if a[] is a singleton
    ) | t               //   end of map(); yield t
  :                     // else:
    t += !n             //   increment t if n = 0