Skip to content

Commit

Permalink
2016 day 16 - fix minor inconsistency
Browse files Browse the repository at this point in the history
Signed-off-by: Lance-Drane <ldraneutk@gmail.com>
  • Loading branch information
Lance-Drane committed Jan 6, 2024
1 parent 20077e0 commit 45da877
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions 2016/16/1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def flip_bits(binary_str: str):
inverse = int(binary_str, 2) ^ (2 ** (len(binary_str) + 1) - 1)
inverse = int(binary_str, 2) ^ ((1 << (len(binary_str) + 1)) - 1)
return bin(inverse)[3:]


Expand All @@ -8,7 +8,7 @@ def flip_bits(binary_str: str):
data = input()
while len(data) < TARGET_LENGTH:
data = f'{data}0{flip_bits(data[::-1])}'
data = data[:TARGET_LENGTH]
data = list(data[:TARGET_LENGTH])

while len(data) & 1 != 1:
# in python 3.12, can potentially use itertools.batched instead
Expand Down
4 changes: 2 additions & 2 deletions 2016/16/2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def flip_bits(binary_str: str):
inverse = int(binary_str, 2) ^ (2 ** (len(binary_str) + 1) - 1)
inverse = int(binary_str, 2) ^ ((1 << (len(binary_str) + 1)) - 1)
return bin(inverse)[3:]


Expand All @@ -8,7 +8,7 @@ def flip_bits(binary_str: str):
data = input()
while len(data) < TARGET_LENGTH:
data = f'{data}0{flip_bits(data[::-1])}'
data = data[:TARGET_LENGTH]
data = list(data[:TARGET_LENGTH])

while len(data) & 1 != 1:
# in python 3.12, can potentially use itertools.batched instead
Expand Down

0 comments on commit 45da877

Please sign in to comment.