Advertisement
nq1s788

24 паттерн с ифами

Nov 13th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. s = open('').readline()
  2. d = 0
  3. answ = 0
  4. for i in range(len(s)):
  5.     if (d != 0) and ((s[i - 1] == 'X' and s[i] == 'Y') or (s[i - 1] == 'Y' and s[i] == 'Z') or (s[i - 1] == 'Z' and s[i] == 'X')):
  6.         d += 1
  7.         answ = max(answ, d)
  8.     elif s[i] == 'X':
  9.         d = 1
  10.     else:
  11.         d = 0
  12. print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement