AOC22/day6/main.py

19 lines
517 B
Python

with open("day6\input.txt") as f:
data = f.readlines()
'''
Run a kernel of size x over the data an report when the kernel first has x unique characters in it.
As in how many characters is processed before the kernel is filled with unique characters
Objective 1 find when x = 4
Objective 2 find when x = 14
'''
kernel = ["a"]
for num,char in enumerate(data[0]):
kernel.append(char)
if len(kernel) > 14:
kernel.pop(0)
if len(set(kernel)) == 14:
print(num+1)
break