Ding! The “fasten seat belt” signs have turned on. Time to find your seat.
It’s a completely full flight, so your seat should be the only missing boarding pass in your list. However, there’s a catch: some of the seats at the very front and back of the plane don’t exist on this aircraft, so they’ll be missing from your list as well.
Your seat wasn’t at the very front or back, though; the seats with IDs +1 and -1 from yours will be in your list.
What is the ID of your seat? Determine this in the following way:
row
that takes a seat (str
). The function must return at which row (int
) the given seat is located.column
that takes a seat (str
). The function must return at which column (int
) the given seat is located.seat_id
that takes a seat (str
). The function must return the seat ID (int
) of the given seat.missing_seat_id
that takes the pathname (str
) of a text file containing a list of boarding passes: each line contains the seat of a boarding pass. The function must return the missing seat ID (int
) on the given list of boarding passes.In this interactive session we assume the text file boarding_list.txt
1 to be located in the current directory.
>>> row('FBFBBFFRLR')
44
>>> row('BFFFBBFRRR')
70
>>> row('FFFBBBFRRR')
14
>>> row('BBFFBBFRLL')
102
>>> column('FBFBBFFRLR')
5
>>> column('BFFFBBFRRR')
7
>>> column('FFFBBBFRRR')
7
>>> column('BBFFBBFRLL')
4
>>> seat_id('FBFBBFFRLR')
357
>>> seat_id('BFFFBBFRRR')
567
>>> seat_id('FFFBBBFRRR')
119
>>> seat_id('BBFFBBFRLL')
820
>>> missing_seat_id('boarding_list.txt')
658