summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-12-03 10:55:52 +0000
committerTomasz Kramkowski <tk@the-tk.com>2021-12-03 10:55:52 +0000
commitd2d7ede396c4349db45615f05a11c38540a4040c (patch)
tree9453cd1e616f68928764870af437af23afa3536f
parentc45449b1a1cd0eee0c481e1a4f784686e44bb49d (diff)
downloadaoc2021-d2d7ede396c4349db45615f05a11c38540a4040c.tar.gz
aoc2021-d2d7ede396c4349db45615f05a11c38540a4040c.tar.xz
aoc2021-d2d7ede396c4349db45615f05a11c38540a4040c.zip
day 3 part 2: minor bugfix
-rw-r--r--3.py2
1 files changed, 1 insertions, 1 deletions
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]