From e1b1a11dae7ebd5c59e93f9020bb9a0375ce9637 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 8 Dec 2022 17:45:53 +0100 Subject: [PATCH] Solve day6 part 2 --- 2022/day06_signal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/2022/day06_signal.py b/2022/day06_signal.py index 53fdeb7..71bc0f0 100644 --- a/2022/day06_signal.py +++ b/2022/day06_signal.py @@ -46,9 +46,13 @@ def sliding_window(stream: str, size: int) -> Generator[str]: def solve_part_2(data: DataType) -> int: + size = 14 + for index, window in enumerate(sliding_window(data, size)): + if not repeating(window): + return index + size return 0 if __name__ == "__main__": - main("inputs/day06-test1", expected_part_1=10) - main("inputs/day06", expected_part_1=1578) + main("inputs/day06-test1", expected_part_1=10, expected_part_2=29) + main("inputs/day06", expected_part_1=1578, expected_part_2=2178)