From d1ddf896483a8679ef6e33cd207e8a3482513803 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 3 Dec 2021 20:13:07 +0000 Subject: day 3: performance improvement --- 3.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '3.py') 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: -- cgit v1.2.3-54-g00ecf