From d2d7ede396c4349db45615f05a11c38540a4040c Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 3 Dec 2021 10:55:52 +0000 Subject: day 3 part 2: minor bugfix --- 3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.py b/3.py index 32596ef..2eed1b7 100644 --- a/3.py +++ b/3.py @@ -11,7 +11,7 @@ def column(rows: Iterable[Bits], n: int) -> Generator[bool, None, None]: def most_common(bits: Iterable[bool]) -> bool: freqs: list[tuple[bool, int]] = Counter(bits).most_common() - if freqs[0][1] == freqs[1][1]: + if len(freqs) > 1 and freqs[0][1] == freqs[1][1]: return True return freqs[0][0] -- cgit v1.2.3-54-g00ecf