Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('24_5810.txt', 'r') as f:
- data = f.read().strip() +'___'
- skip = 0
- c = 1
- k = 0
- k_max = 0
- for i in range(len(data) - 3):
- if skip:
- if c == skip:
- skip = 0
- c = 1
- else:
- c += 1
- continue
- if data[i] + data[i + 1] + data[i + 2] == 'XYZ':
- skip = 3
- k += 3
- k_max = max(k, k_max)
- elif data[i] + data[i + 1] in ['XY', 'YZ']:
- skip = 2
- k += 2
- k_max = max(k, k_max)
- else:
- k = 0
- skip = 1
- c = 1
- print(k_max)
Advertisement
Add Comment
Please, Sign In to add comment