advent_of_code/2022/6/6.py
kleph f821d3ceae
All checks were successful
continuous-integration/drone/push Build is passing
2022 - Day 6 part 1
2022-12-06 20:18:42 +01:00

20 lines
540 B
Python

#!/usr/bin/env python
# 2022 - Advent Of Code 6
# file = 'input_example.txt'
file = 'input.txt'
previous = []
count = 0
with open(file, encoding="utf-8") as f:
signal = f.readline().strip()
for c in signal:
count += 1
if c in previous:
pos = previous.index(c)
# print(f'[{count}]{c} already found at {pos}')
previous = previous[pos+1:]
elif len(previous) == 3:
print(f'start of signal found at position {count}')
break
previous.append(c)