def read_file(): with open("input.txt","r") as f: return f.read().split('\n') def id(seat): """ Translate to binary. """ return int(seat.translate(str.maketrans('FBLR', '0101')), 2) def part1(seats): """ Find the highest seat ID. """ ids = sorted(map(id, seats)) return max(ids) def part2(seats): """ Find your seat ID, which is missing. """ ids = sorted(map(id, seats)) return sum( range(min(ids), max(ids)+1) ) - sum(ids) def main(): seats = read_file() print(f'{part1(seats)=}') print(f'{part2(seats)=}') if __name__ == "__main__": main()