06_packets.py 437 B

123456789101112131415
  1. #!/usr/bin/env python3
  2. import sys
  3. from collections import Counter, deque
  4. def marker(stream, winlen):
  5. window = deque(stream[:winlen - 1])
  6. for i, char in enumerate(stream[winlen - 1:]):
  7. if char not in window and len(Counter(window)) == winlen - 1:
  8. return i + winlen
  9. window.popleft()
  10. window.append(char)
  11. stream = sys.stdin.readline().rstrip()
  12. print(marker(stream, 4))
  13. print(marker(stream, 14))