This one was fun! Using python for this felt like cheating, honestly. Doing the challenge right after breakfast made everything seem easier too.

This never happens in real life, because I hold onto my boarding pass and ID in my sweaty little hands for the entire time I'm in the airport.

This never happens in real life, because I hold onto my boarding pass and ID in my sweaty little hands for the entire time I'm in the airport.

Best Time Yet!

Best Time Yet!

Anecdotally, I spent almost 6 minutes reading the problem statement before writing any code. If I had gotten the critical mapping sooner, I could have cut my time in half easily. I wonder if using some sort of screen recording + reviewing time spent later might help me improve my times, like suggested by that one Dan Luu post. In a sense, every one of these puzzles is based on recognizing a standard problem / structure, and adjusting for the problem-specific peculiarities.

The critical insight for part 1 was that this: FBFBFBF == 0101010; exactly how an integer is stored in a most-significant-bit encoding. Python’s tools for working with strings and binary conversion made this a breeze. Part 2 was straightforward data munging; find the missing id in a sorted list. I did part 2 in the shell with numpy in about a minute.

def boarding_pass_row(seq):
    assert len(seq) == 7
    seqb = seq.replace('F', '0').replace('B', '1')
    return int(seqb, 2)

def boarding_pass_col(seq):
    assert len(seq) == 3
    seqb = seq.replace('R', '1').replace('L', '0')
    return int(seqb, 2)

def row_id(seq):
    row, col = boarding_pass_row(seq[:7]), boarding_pass_col(seq[7:])
    return 8 * row + col

For the full code, like and subscribe to my github. This episode sponsored by nothing and no one; “Feel the call of the void!”™.