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.")
|
print("Naive react says: More reacting is possible.")
|
||||||
|
|
||||||
def react(pol):
|
def react(pol):
|
||||||
start = 0
|
|
||||||
while True:
|
while True:
|
||||||
i = start
|
i = 0
|
||||||
while i < len(pol) - 1:
|
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]
|
||||||
del pol[i]
|
del pol[i]
|
||||||
start = max(0, start - 1)
|
i = max(0, i - 1)
|
||||||
break
|
else:
|
||||||
elif i == start + 1:
|
i += 1
|
||||||
start = i
|
|
||||||
i += 1
|
|
||||||
else:
|
else:
|
||||||
return
|
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):
|
def result(pol):
|
||||||
l = pol.copy()
|
l = pol.copy()
|
||||||
#print("".join(l))
|
#print("".join(l))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue