You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
410 B
25 lines
410 B
2 years ago
|
import aoclib
|
||
|
from collections import deque
|
||
|
|
||
|
|
||
|
inp = aoclib.get_input(6)
|
||
|
|
||
|
|
||
|
def find_marker(message, after=4):
|
||
|
buf = deque([], maxlen=after)
|
||
|
for i, letter in enumerate(message, 1):
|
||
|
buf.append(letter)
|
||
|
if len(buf) == after and len(set(buf)) == after:
|
||
|
return i
|
||
|
|
||
|
|
||
|
def part1():
|
||
|
return find_marker(inp)
|
||
|
|
||
|
|
||
|
def part2():
|
||
|
return find_marker(inp, 14)
|
||
|
|
||
|
|
||
|
aoclib.main(part1, part2)
|