initial commit, day 10
This commit is contained in:
27
04b_alt.py
Executable file
27
04b_alt.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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_}')
|
||||
Reference in New Issue
Block a user