You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
570 B
23 lines
570 B
|
|
|
|
# Get ID
|
|
def to_binary(line):
|
|
line = line.replace('B', '1').replace('F', '0').replace('R', '1').replace('L', '0')
|
|
return int(line, 2)
|
|
|
|
|
|
with open(r"C:\Users\Maya\Desktop\Uni\WS_2021\AoC\input05") as f:
|
|
lines = f.readlines()
|
|
nums = [to_binary(line) for line in lines]
|
|
|
|
# Find biggest seat-ID
|
|
print(max(nums))
|
|
|
|
# Find missing seat-ID
|
|
for num in nums:
|
|
if (num in nums) and (num+2 in nums) and (num+1 not in nums):
|
|
print(num+1)
|
|
|
|
for i in range(min(nums), max(nums)+1):
|
|
if i not in nums:
|
|
print(i)
|
|
|