View difference between Paste ID: ejSCVhcF and bZVFzJec
SHOW: | | - or go back to the newest paste.
1
stairs = (20, 30, 50, 30)
2
max_step = 100
3
4
def main(stairs, max_step):
5
    known = dict()
6
    p = possibilities(stairs, max_step, known)
7
    print(p)
8
9
def possibilities(stairs, max_step, known):
10-
    ind = 4- len(stairs)
10+
11
        return 1
12
    
13
    p = 0
14
    for i in range(1,len(stairs)+1): 
15
        down = stairs[:i]
16
        up= stairs[i:]
17
18
        if sum(down) > max_step:
19
            break
20
        elif up in known:
21
            p += known[up]
22
        else:
23
            p_up = possibilities(up, max_step, known)
24
            known[up] = p_up
25
            p += p_up
26
    return p
27
28
main(stairs, max_step)