Advertisement
Korotkodul

N24

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