Advertisement
nq1s788

24(xyzxyzx..)

May 18th, 2024
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. #https://inf-ege.sdamgia.ru/problem?id=27689
  2. data = open('24_demo.txt').readline()
  3. s = 'XYZ'
  4. cnt = 0 #длина текущей строки
  5. mx = 0 #ответ -- максимальная длина среди найденных
  6. for x in data: #x -- текущая буква
  7.     if x == s[cnt % 3]:
  8.         cnt += 1
  9.         if cnt > mx:
  10.             mx = cnt
  11.     else:
  12.         cnt = 0
  13. print(mx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement