23 lines
417 B
Python
23 lines
417 B
Python
# Python!
|
|
import re
|
|
|
|
with open('07.txt') as file:
|
|
rows = file.read().splitlines()
|
|
|
|
abba = re.compile(r'(\w)(\w)(?<!\1)\2\1')
|
|
hynet_seq = re.compile('\[[^\]]*\]')
|
|
|
|
count = 0
|
|
for row in rows:
|
|
valid = False
|
|
stripped = hynet_seq.sub('|', row)
|
|
hynets = hynet_seq.finditer(row)
|
|
|
|
if abba.search(stripped): valid = True
|
|
|
|
for h in hynets:
|
|
if abba.search(h.group()): valid = False
|
|
|
|
if valid: count += 1
|
|
|
|
print(count) |