with open('data-2020-05.txt', 'r') as f:
bp = f.read().splitlines()Advent of Code 2020 Day 5
— Day 5: Binary Boarding —
You dropped your boarding pass, and now have to find your seat.
As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?
This is weird data but a short solution
# row and col binary via replacement
row = [x[:7].replace("B", "1").replace("F", "0") for x in bp]
col = [x[7:].replace("L", "0").replace("R", "1") for x in bp]
# id as a combo of row and col
id = [int(r, 2) * 8 + int(c, 2) for r, c in zip(row, col)]
#part a
max(id)970
— Part Two —
You have to find your seat number, quick!
What is the ID of your seat?
# part b
set(range(min(id), max(id))) - set(id){587}