Log in to get your input and submit your answers.

Day 05: Binary Boarding

Once past the turnstiles, you dash towards the cluster to take the retake exam. But to stop students from sitting next to their friends to cheat, Le Bocal implemented an unusual seating system.

Instead of directly telling you your station, the terminal prints a ticket with a code based on Binary Space Partitioning (BSP).

A code is exactly 10 characters: the first 7 denote the row and the last 3 denote the column of the station.

The cluster has 128 rows of desks, numbered from 0 to 127. Each letter divides the remaining range into halves: F means the front half (Front), and B means the back half (Back).

Consider, for example, the first 7 characters of FBFBBFFRLR :

The last 3 characters work under the same principle across 8 columns (numbered 0 through 7). This time, L selects the left half (Left) and R selects the right half (Right):

The ticket FBFBBFFRLR therefore corresponds to row 44 and column 5.

Every station has a unique Seat ID obtained by multiplying the row by 8 and adding the column: 44 * 8 + 5 = 357.

Part 1

Here are examples of decoding other exam tickets:

You obtain the file containing the list of all tickets assigned to the students present.

Analyzing every ticket in your list, what is the highest seat ID (Seat ID)?