34 lines
635 B
Python
34 lines
635 B
Python
# import re
|
|
#
|
|
# with open('24_7.txt', 'r') as file:
|
|
# data = file.readline()
|
|
#
|
|
# data = re.sub('CD', '--', data)
|
|
#
|
|
# not_CD = r'(-?[^-]*)'
|
|
#
|
|
# CD_and_any = r'(?:--[^-]*){160}-?'
|
|
# la_CD_group = rf'(?=({CD_and_any}))'
|
|
#
|
|
# pattern = rf'{not_CD}{la_CD_group}'
|
|
#
|
|
# matches = re.findall(pattern, data)
|
|
#
|
|
# res = max([len(match[0] + match[1])
|
|
# for match in matches])
|
|
# print(res)
|
|
from itertools import count
|
|
|
|
|
|
f = open('24_7.txt').read()
|
|
a=[]
|
|
j=0
|
|
count = 0
|
|
for i in range(len(f)-1):
|
|
if f[i]+f[i+1]=='CD':
|
|
count+=1
|
|
if count>160:
|
|
count=1
|
|
a.append(i+1-j)
|
|
j=i
|
|
print(max(a)) |