-
Notifications
You must be signed in to change notification settings - Fork 0
/
2466.py
61 lines (53 loc) · 1 KB
/
2466.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class Solution(object):
def countGoodStrings(self, l, h, z, o):
"""
:type low: int
:type high: int
:type zero: int
:type one: int
:rtype: int
"""
global low
global high
global zero
global one
global dp
global xxx
low=l
high=h
zero=z
one=o
dp={}
def next_state(index):
if index>=low and index not in dp:
dp[index]=1
elif index>=low:
dp[index]+=1
for i in [zero,one]:
if index+i<=high:
next_state(index+i)
print(index)
next_state(0)
#
# for i in list(dp.keys()):
# if i <low:
# dp.pop(i)
return sum(list(dp.values()))
#%%
low = 200
high = 200
zero = 10
one = 1
x=Solution
x.countGoodStrings(x,low,high,zero,one)
#%%
a=0
def x():
global a
a=a+1
x()
a
#%%
a=1
list=[1,2]
sum(list)