Last active
December 6, 2022 05:27
-
-
Save abeland/dfe4e6425c0431ebe6c6c60a0ce6fa7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
from input import INPUT | |
def _detect_start_of_msg(s: str, n: int) -> int: | |
d = deque(s[0:n]) | |
i = n | |
while len(set(d)) < n: | |
d.popleft() | |
d.append(s[i]) | |
i += 1 | |
return i | |
def part1() -> int: | |
return _detect_start_of_msg(INPUT, 4) | |
def part2() -> int: | |
return _detect_start_of_msg(INPUT, 14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment