solution.py 432 B

123456789101112131415161718
  1. #!/usr/bin/python3
  2. import sys
  3. def search_distinct_set(datastream, length):
  4. index = length
  5. while len(set(datastream[index - length:index])) != length:
  6. index += 1
  7. #print(window, list(set(window)))
  8. return index
  9. def solution(length):
  10. for line in sys.stdin:
  11. print(f'first marker after character {search_distinct_set(line, length)}')
  12. if sys.argv[1] in '1':
  13. solution(4)
  14. else:
  15. solution(14)