diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-03 20:13:07 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-03 20:13:07 +0000 |
commit | d1ddf896483a8679ef6e33cd207e8a3482513803 (patch) | |
tree | d1d63ec543657ee0fea826e56c9439461966f041 | |
parent | d75a9d510ced0a29ad2fe7ebc247dc7b0766320c (diff) | |
download | aoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.tar.gz aoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.tar.xz aoc2021-d1ddf896483a8679ef6e33cd207e8a3482513803.zip |
day 3: performance improvement
-rw-r--r-- | 3.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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: |