def get_id(bpass):
    replace = {'F': '0',
               'B': '1',
               'L': '0',
               'R': '1'}
    
    for k, v in replace.items():
        bpass = bpass.replace(k, v)
    return int(bpass, 2)

if __name__ == '__main__':
    with open("input.txt") as f:
        data = f.read().splitlines()

    # part 1
    ids = [get_id(bpass) for bpass in data]
    print(f'Part 1: {max(ids)}')
    
    # part 2
    ids = sorted(ids)
    
    import numpy as np
    diff = np.array([ids[i+1] - ids[i] for i in range(len(ids) - 1)])
    idx = np.where(diff > 1)[0][0]
    print(f'Part 2: {(ids[idx] + 1)}')
    
    # part 2 without numpy
    for i in range(len(ids) - 1):
        if ids[i+1] - ids[i] == 2:
            print(f'Part 2: {ids[i] + 1}')
            break