boarding_passes = [] with open('day5/input') as reader: boarding_passes.extend(reader.read().splitlines()) def seat_id(boarding): binary = boarding \ .replace('F', '0') \ .replace('B', '1') \ .replace('L', '0') \ .replace('R', '1') return int(binary, 2) res = max(map(seat_id, boarding_passes)) print(res) # second part all_seats = sorted(map(seat_id, boarding_passes)) for i in range(len(all_seats)): if all_seats[i] + 2 == all_seats[i + 1]: print(all_seats[i] + 1) break