From f3879102140c4632e99366a07a8898dad8f83513 Mon Sep 17 00:00:00 2001 From: Victor Alexandrovich Tsyrenschikov <77172321+tsyrenschikov@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:44:29 +0500 Subject: [PATCH] project --- 24.7.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/24.7.py b/24.7.py index f7b032b..0a32c81 100644 --- a/24.7.py +++ b/24.7.py @@ -25,8 +25,27 @@ # a.append(i) # print(max([p1-p for p,p1 in zip(a, a[161:])])) -lst1 = [0, 1, 2, 3, 4, 5, 7, 8, 9, 10] -# lst2 = [5, 3, 2, 0, 4, 1] -# lst3 = ['нуль', 'один', 'два', 'три', 'четыре', 'пять'] -for a, b in zip(lst1,lst1[8:]): - print(f'{a} {b}') \ No newline at end of file + + + + + + +f = open('24_7.txt').read().strip() +cd = 0 +two = 0 +max_len = 0 + +for i in range(len(f)-1): + if f[i] + f[i+1]== 'CD': + cd += 1 + + while cd > 160: + if f[two]=='C' and f[two+1] == 'D': + cd -= 1 + two += 1 + + if cd == 160: + max_len = max(max_len, i - two+2) + +print(max_len) \ No newline at end of file