Advertisement
Korotkodul

N1_v3_ok

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