-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd7.py
41 lines (36 loc) · 869 Bytes
/
d7.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
inp = open('input_d7.txt').read()
i = inp.split('\n')[:-1]
import re
ins = set()
t = True
def check_aba(s):
for k in range(len(s)-2):
print(s[k:k+2], s[k+1:k+3])
if s[k:k+2] == s[k+1:k+3][::-1] and s[k] != s[k+1]:
if t:
ins.add(s[k:k+2][::-1] + s[k+1])
print(ins)
elif s[k:k+3] in ins:
print("True")
return True
else:
print(ins)
print("Fail " + s[k:k+3])
return False
count = 0
for j in i:
ins = set()
hyp = re.findall(r'\[([^\]]+)\]', j)
st = []
st.append(j.split('[',1)[0])
st += re.findall(r'\]([^\[]*)',j)
print(j)
print(st)
print(hyp)
t = True
map(check_aba, hyp)
t = False
print("Checking")
if any(map(check_aba,st)):
count += 1
print(count)