Files
pythonProject/24.7.py
Victor Alexandrovich Tsyrenschikov 31f50d9a08 24.7
2025-11-21 00:49:49 +05:00

30 lines
606 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])
s = open('24_7.txt').readline().strip()
pos = [-1]
for p in range(len(s) - 1):
if s[p]+s[p+1] == 'CD':
pos.append(p)
pos.append(len(s) - 1)
ml = 0
for p, p1 in zip(pos, pos[161:]):
ml = max(ml, p1 - p)
print(ml)