class SeatPass: def __init__(self, seatcode): self.getrow(seatcode[:7]) self.getcol(seatcode[7:]) self.getseat() def getrow(self, seatcode): seatcode = seatcode.replace('F', '0') seatcode = seatcode.replace('B', '1') self.row = int(seatcode, 2) def getcol(self, seatcode): seatcode = seatcode.replace('L', '0') seatcode = seatcode.replace('R', '1') self.col = int(seatcode, 2) def getseat(self): self.seatnum = (self.row * 8) + self.col def main(): with open('input5.txt') as file: lines = file.readlines() lines = [line.strip() for line in lines] passes = [] maxseat = -1 for line in lines: p = SeatPass(line) passes.append(p) if p.seatnum > maxseat: maxseat = p.seatnum print(f"The largest seat number I've seen is {maxseat}.") if __name__ == "__main__": main()