advent-of-code/2022/day6.py
Mikaël Capelle 8a0412f926 Clean 2022.
2023-12-09 09:54:53 +01:00

16 lines
344 B
Python

import sys
def index_of_first_n_differents(data: str, n: int) -> int:
for i in range(len(data)):
if len(set(data[i : i + n])) == n:
return i + n
return -1
data = sys.stdin.read().strip()
print(f"answer 1 is {index_of_first_n_differents(data, 4)}")
print(f"answer 2 is {index_of_first_n_differents(data, 14)}")