zhukov000

24

Jun 24th, 2021
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. with open("24.txt") as file:
  2.   s = file.readline().strip()
  3.   n = len(s)
  4.  
  5.   cur = mx = 1
  6.   for i in range(1, n):
  7.     if (s[i] == "d" and s[i-1] == "a") or (s[i] == "a" and s[i-1] == "d"):
  8.       cur = 1
  9.     else:
  10.       cur += 1
  11.     mx = max(mx, cur)
  12.   print(mx)
  13.  
Advertisement
Add Comment
Please, Sign In to add comment