summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--3.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/3.py b/3.py
index 8d27cf2..29cae70 100644
--- a/3.py
+++ b/3.py
@@ -28,9 +28,7 @@ def part1(nums: Input) -> int:
def part2_impl(nums: Input, complement: bool, bit: int = 0) -> Bits:
if len(nums) == 1:
return nums[0]
- target: bool = most_common(column(nums, bit))
- if complement:
- target = not target
+ target: bool = most_common(column(nums, bit)) ^ complement
nums = list(filter(lambda n: n[bit] == target, nums))
return part2_impl(nums, complement, bit + 1)