Advertisement
Korotkodul

N10

Apr 20th, 2023
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. s = ''
  2. with open('24.txt') as f:
  3.     s = f.readline()
  4.  
  5. s = s.replace('AA', '*')
  6. a = s.split('*')
  7. #print(s)
  8. #print(a)
  9.  
  10. kmax = 1
  11. #1, posl - otdel
  12. t = a[0]
  13. if len(t) != 0:
  14.     k = len(t) + 1
  15.     if t[-1] == 'A':
  16.         k -= 1
  17.     kmax = max(k, kmax)
  18.  
  19. t = a[-1]
  20. if len(t) != 0:
  21.     k = len(t) + 1
  22.     if t[0] == 'A':
  23.         k -= 1
  24.     kmax = max(k, kmax)
  25.  
  26. for i in range(1, len(a) - 1):
  27.     t = a[i]
  28.     if len(t) == 0:
  29.         continue
  30.     k = len(t) + 2
  31.     if t[0] == 'A':
  32.         k -= 1
  33.     if t[-1] == 'A':
  34.         k -= 1
  35.     kmax = max(k, kmax)
  36. print(kmax)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement