def locate_seat( boarding_pass ):
    """
    The plane contains 128 rows and 8 columns. Each boarding pass
    describes how to locate the corresponding seat by recursively
    splitting the plane in half in either the 'Front', 'Back',
    'Left', or 'Right' directions. 

    e.g., A boarding pass looks like: 'FBFBBFFRLR', where the last
    three characters describe the column, and the first part describes
    the row of the seat.

    This function returns the seat ID which is found by (row*8) + column
    """
    def get_partition( low, high, b_pass, region ): 
        if b_pass != '':
            if b_pass[0] == region[0]:
                low  = low
                high = (high + low - 1)//2
                return get_partition( low, high, b_pass[1:], region )
            elif b_pass[0] == region[1]:
                low  = (high + low + 1)//2
                high = high
                return get_partition( low, high, b_pass[1:], region )
            else:
                raise ValueError('invalid region, should be F or B')
        else:
            assert low == high
            return low
    row = get_partition( 0, 127, boarding_pass[:-3], ['F','B'] )
    col = get_partition( 0, 7,   boarding_pass[-3:], ['L','R'] )
    return row * 8 + col