You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
576 B
Python

#!/usr/bin/env python3
INPUT_FILE = 'input'
WINDOW_SIZE = 4
def main():
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
for line in content:
seen_chars = []
char_pos = 0
for char in line:
char_pos += 1
if len(seen_chars) == WINDOW_SIZE:
seen_chars.pop(0)
seen_chars.append(char)
if len(set(seen_chars)) == WINDOW_SIZE:
print(seen_chars, char)
print(char_pos)
break
if __name__ == '__main__':
main()