Advertisement
maxim_shlyahtin

24

Feb 1st, 2022
987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. with open('c8c8a1ca-a3d8-461f-b43b-3473a40a7d83.txt', 'r') as file:
  2.     a = file.readline()
  3.  
  4. cur_dist = 1
  5. max_dist = 1
  6. a_counter = 0
  7. last_pos = 0
  8.  
  9. i = 0
  10. while i < len(a):
  11.     if a[i] == 'A':
  12.         a_counter += 1
  13.     if a_counter == 0:
  14.         cur_dist += 1
  15.     elif a_counter == 1:
  16.         cur_dist += 1
  17.         last_pos += 1
  18.     elif a_counter == 2:
  19.         max_dist = max(max_dist, cur_dist)
  20.         cur_dist = 1
  21.         a_counter = 0
  22.         i -= last_pos - 1
  23.         last_pos = 0
  24.     i += 1
  25.  
  26.  
  27. print(max_dist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement