28 lines
611 B
Python
Executable File
28 lines
611 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
import re
|
|
|
|
with open('04a.txt') as f:
|
|
text = f.read().strip().replace('\n', 'Z')
|
|
|
|
TOP = r'M[^Z]M.{139}A.{139}S[^Z]S'
|
|
LEFT = r'M[^Z]S.{139}A.{139}M[^Z]S'
|
|
BOTTOM = r'S[^Z]S.{139}A.{139}M[^Z]M'
|
|
RIGHT = r'S[^Z]M.{139}A.{139}S[^Z]M'
|
|
|
|
T = re.compile(f'(?={TOP})')
|
|
L = re.compile(f'(?={LEFT})')
|
|
B = re.compile(f'(?={BOTTOM})')
|
|
R = re.compile(f'(?={RIGHT})')
|
|
|
|
T_ = len(T.findall(text))
|
|
L_ = len(L.findall(text))
|
|
B_ = len(B.findall(text))
|
|
R_ = len(R.findall(text))
|
|
|
|
print(f'TOP {T_}')
|
|
print(f'LEFT {L_}')
|
|
print(f'BOTTOM {B_}')
|
|
print(f'RIGHT {R_}')
|
|
print(f'TOTAL {T_ + L_ + B_ + R_}')
|