summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2021-12-03 20:13:07 +0000
committerTomasz Kramkowski <tk@the-tk.com>2021-12-03 20:13:07 +0000
commitd1ddf896483a8679ef6e33cd207e8a3482513803 (patch)
treed1d63ec543657ee0fea826e56c9439461966f041
parentd75a9d510ced0a29ad2fe7ebc247dc7b0766320c (diff)
downloadaoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.tar.gz
aoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.tar.xz
aoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.zip
day 3: performance improvement
-rw-r--r--3.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/3.py b/3.py
index 6e77680..58e8f4f 100644
--- a/3.py
+++ b/3.py
@@ -4,7 +4,8 @@ Bits = tuple[bool, ...]
Input = list[Bits]
def most_common(nums: list[Bits], n: int) -> bool:
- count = sum(num[n] for num in nums)
+ count: int = 0
+ for num in nums: count += num[n]
return count >= len(nums) - count
def bits_to_int(bits: Bits) -> int: