Attempt to clean up 2018/05
This commit is contained in:
parent
4883db17b5
commit
20d18558c5
1 changed files with 22 additions and 8 deletions
|
|
@ -15,21 +15,35 @@ def naive_react(pol):
|
|||
print("Naive react says: More reacting is possible.")
|
||||
|
||||
def react(pol):
|
||||
start = 0
|
||||
while True:
|
||||
i = start
|
||||
i = 0
|
||||
while i < len(pol) - 1:
|
||||
if pol[i].lower() == pol[i+1].lower() and pol[i] != pol[i+1]:
|
||||
pol_cur, pol_next = pol[i], pol[i+1]
|
||||
if pol_cur.lower() == pol_next.lower() and pol_cur != pol_next:
|
||||
del pol[i]
|
||||
del pol[i]
|
||||
start = max(0, start - 1)
|
||||
break
|
||||
elif i == start + 1:
|
||||
start = i
|
||||
i += 1
|
||||
i = max(0, i - 1)
|
||||
else:
|
||||
i += 1
|
||||
else:
|
||||
return
|
||||
|
||||
#def react(pol):
|
||||
# start = 0
|
||||
# while True:
|
||||
# i = start
|
||||
# while i < len(pol) - 1:
|
||||
# if pol[i].lower() == pol[i+1].lower() and pol[i] != pol[i+1]:
|
||||
# del pol[i]
|
||||
# del pol[i]
|
||||
# start = max(0, start - 1)
|
||||
# break
|
||||
# elif i == start + 1:
|
||||
# start = i
|
||||
# i += 1
|
||||
# else:
|
||||
# return
|
||||
|
||||
def result(pol):
|
||||
l = pol.copy()
|
||||
#print("".join(l))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue