-
Notifications
You must be signed in to change notification settings - Fork 0
/
649.py
56 lines (47 loc) · 1.48 KB
/
649.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
class Solution(object):
def predictPartyVictory(self, senate):
"""
:type senate: str
:rtype: str
"""
while True:
if 'R' not in senate:
return 'Dire'
elif 'D' not in senate:
return 'Radiant'
else:
checker = 0
while checker<len(senate):
# if checker==len(senate)-1 and senate[checker]!=' ':
# if senate[checker] == 'R':
# senate =senate.replace('D', ' ', 1)
# elif senate[checker] == 'D':
# senate =senate.replace('R', ' ', 1)
if senate[checker]=='R':
if 'D' in senate[checker:]:
senate=senate[:checker]+senate[checker:].replace('D',' ',1)
else:
senate = senate.replace('D', ' ', 1)
elif senate[checker]=='D':
if 'R' in senate[checker:]:
senate=senate[:checker]+senate[checker:].replace('R',' ',1)
else:
senate = senate.replace('R', ' ', 1)
checker+=1
#%%
x=Solution
Solution.predictPartyVictory(x,'DRRDRDRDRDDRDRDR')
#%%
# a='sdafewraaaaa'
# i=0
# while i < len(a):
#
# b=a[i]
# print(b)
# a=a.replace('a','',1)
# i += 1
#%%
a='abcdeft'
len(a)
#%%
a[6]