2022 - Day 6 part 2
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kleph 2022-12-06 20:21:49 +01:00
parent f821d3ceae
commit 51adcdcec1

20
2022/6/6_2.py Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python
# 2022 - Advent Of Code 6 part 2
# 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) == 13:
print(f'start of signal found at position {count}')
break
previous.append(c)