From 675fa882e0cc932a08ef64ba056e4c238be0c6d0 Mon Sep 17 00:00:00 2001 From: Victor Alexandrovich Tsyrenschikov <77172321+tsyrenschikov@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:59:19 +0500 Subject: [PATCH] project --- 24.7.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/24.7.py b/24.7.py index d9c12bf..01c5475 100644 --- a/24.7.py +++ b/24.7.py @@ -17,11 +17,18 @@ # res = max([len(match[0] + match[1]) # for match in matches]) # print(res) +from itertools import count -f = open('24_7.txt').readline() -f = f.replace('CD', 'C D').split() -m = 0 -for i in range(len(f)-161): - a=''.join(f[i:i+161]) - m = max(m, len(a)) -print(m) \ No newline at end of file + +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)) \ No newline at end of file