From fdb7fe64e64a22518f4699ddcbc49fad95f8da18 Mon Sep 17 00:00:00 2001 From: aaron Date: Tue, 6 Dec 2022 16:47:14 +0100 Subject: [PATCH] fix comments --- 6/tuningtrouble.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/6/tuningtrouble.py b/6/tuningtrouble.py index cb083d2..c3f256f 100644 --- a/6/tuningtrouble.py +++ b/6/tuningtrouble.py @@ -1,16 +1,14 @@ -from itertools import count - from aocd.models import Puzzle from aocd import submit def get_marker_pos(signal, N): """ - iterate over input stream and find all the first occurence - where the Set from i to i+N equals N. This means there are - no duplicates within this particular range. + iterate over input signal and find the first occurence + where the set from i to i+N equals N. This means there + are no duplicates within this particular range. """ - for i in count(): + for i in range(0, len(signal)): if len(set(signal[i : i + N])) == N: return i + N @@ -20,12 +18,12 @@ if __name__ == "__main__": puzzle = Puzzle(year=2022, day=6) signal = puzzle.input_data - # part a: + # part a: find marker with 4 different chars answer_a = get_marker_pos(signal, 4) print(f"{answer_a}") submit(answer_a, part="a", day=6, year=2022) - # part b: + # part b: find marker with 14 different chars answer_b = get_marker_pos(signal, 14) print(f"{answer_b}") submit(answer_b, part="b", day=6, year=2022)