diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-03 15:13:42 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-03 15:13:42 +0000 |
commit | 7ccf765434a92ac5b59b8fa85dc701e3572d9b21 (patch) | |
tree | 1940cc0a908648e1ad7f4afcdc12a4c2cd0bbf77 | |
parent | ccad94cf8d9adb60bd9ae1996c83935fc6205e9c (diff) | |
download | aoc2021-7ccf765434a92ac5b59b8fa85dc701e3572d9b21.tar.gz aoc2021-7ccf765434a92ac5b59b8fa85dc701e3572d9b21.tar.xz aoc2021-7ccf765434a92ac5b59b8fa85dc701e3572d9b21.zip |
day 3 part 1: remove superfluous nbits variable
-rw-r--r-- | 3.py | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -15,8 +15,7 @@ def bits_to_int(bits: Bits) -> int: return sum(b * 2 ** i for i, b in enumerate(reversed(bits))) def part1(nums: Input) -> int: - nbits: int = len(nums[0]) - gamma: Bits = tuple(most_common(inp, i) for i in range(nbits)) + gamma: Bits = tuple(most_common(inp, i) for i in range(len(nums[0]))) epsilon: Bits = tuple(not bit for bit in gamma) return bits_to_int(gamma) * bits_to_int(epsilon) |