dxnge

28(3)

Oct 22nd, 2021 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. with open('test.txt') as f:
  2.     frst, snd, thrd, frth = str(), str(), str(), str()
  3.     cnt = 0
  4.     b = 0
  5.     while a := f.read(1):
  6.         frth = a
  7.         if frst+snd+thrd+frth == 'XZZY':
  8.             if cnt < b:
  9.                 cnt = b
  10.             b = 0
  11.         if frst+snd+thrd+frth == 'XZZY':
  12.             b += 3
  13.             if cnt < b:
  14.                 cnt = b
  15.         else:
  16.             b += 1
  17.             if cnt < b:
  18.                 cnt = b
  19.         frst, snd, thrd = snd, thrd, frth
  20. print(cnt)
Add Comment
Please, Sign In to add comment