AdventOfCode/2022/day6.py

15 lines
386 B
Python
Raw Normal View History

2022-12-06 15:35:26 +10:30
with open('input/6', 'r') as file:
line = file.read().strip()
for i in range(len(line)-3):
chars = set(line[i:i+4])
if len(chars) == 4:
print(f'Part 1: first marker after character {i+4}')
break
for i in range(len(line)-13):
chars = set(line[i:i+14])
if len(chars) == 14:
print(f'Part 2: first marker after character {i+14}')
break