2020-12-05

# Day 05: Binary Boarding

Description:
--- Day 5: Binary Boarding ---

You board your plane only to discover a new problem: you dropped your boarding pass! You aren't sure which seat is yours, and all of the flight attendants are busy with the flood of people that suddenly made it through passport control.

You write a quick program to use your phone's camera to scan all of the nearby boarding passes (your puzzle input); perhaps you can find your seat through process of elimination.

Instead of zones or groups, this airline uses binary space partitioning to seat people. A seat might be specified like FBFBBFFRLR, where F means "front", B means "back", L means "left", and R means "right".

The first 7 characters will either be F or B; these specify exactly one of the 128 rows on the plane (numbered 0 through 127). Each letter tells you which half of a region the given seat is in. Start with the whole list of rows; the first letter indicates whether the seat is in the front (0 through 63) or the back (64 through 127). The next letter indicates which half of that region the seat is in, and so on until you're left with exactly one row.

For example, consider just the first seven characters of FBFBBFFRLR:

Start by considering the whole range, rows 0 through 127.
F means to take the lower half, keeping rows 0 through 63.
B means to take the upper half, keeping rows 32 through 63.
F means to take the lower half, keeping rows 32 through 47.
B means to take the upper half, keeping rows 40 through 47.
B keeps rows 44 through 47.
F keeps rows 44 through 45.
The final F keeps the lower of the two, row 44.

The last three characters will be either L or R; these specify exactly one of the 8 columns of seats on the plane (numbered 0 through 7). The same process as above proceeds again, this time with only three steps. L means to keep the lower half, while R means to keep the upper half.

For example, consider just the last 3 characters of FBFBBFFRLR:

Start by considering the whole range, columns 0 through 7.
R means to take the upper half, keeping columns 4 through 7.
L means to take the lower half, keeping columns 4 through 5.
The final R keeps the upper of the two, column 5.

So, decoding FBFBBFFRLR reveals that it is the seat at row 44, column 5.

Every seat also has a unique seat ID: multiply the row by 8, then add the column. In this example, the seat has ID 44 * 8 + 5 = 357.

Here are some other boarding passes:

BFFFBBFRRR: row 70, column 7, seat ID 567.
FFFBBBFRRR: row 14, column 7, seat ID 119.
BBFFBBFRLL: row 102, column 4, seat ID 820.

As a sanity check, look through your list of boarding passes. What is the highest seat ID on a boarding pass?

--- Part Two ---

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?

Input:
FBFBBBFRLL
BFFFBFFRRR
BBFBFFFLLR
FBFFFBFLRR
FBFFBFBLLR
BFBBFBBRLL
BFFFFFFRLR
FBBBBFFLLR
FFBBFFFLRL
FFBFBBFLLR
FBFFFBBRRR
FBFFBFBLRR
FBBFBFFRLR
FBBBFBFRLL
FFBFFBBRLR
FBFBBBFRRL
BFFBBBFRRR
FBFBBBBLLR
FFBFFBBLLL
BFFBFBBLLR
BFFBFBBRLR
BFFBBBBLLL
FBBBBFBLLR
FFBFBBBLRR
FFBFBBFLRR
FFFBFBBRRL
FFFFFBBRLL
BFFFBFFLRR
FFFBFBBRLR
FBFFBBFLLR
BFBFFBBRRR
FBBFBBFLRL
BFBBFBFRRR
BFFFBBBLRL
BBFFFBFLLR
BFFFFBFLRR
BFFBFFBLLL
FFBBFBFRRR
BFBFFFBLLL
FBFBFFFRRR
BFBFBBBLLL
BFFFBBFLLL
BFBFFFBLLR
BFFBBBFRRL
FFFBBFFLLR
BFFBBBFLRR
FBFFBBBRLR
FBBFBBFLRR
FBBFFBFRRR
FBBFBBBRRL
FFFBFFBRRL
FBFBFFBRLL
FBFFBBFRLL
BFBFBFFRLL
FBFBFFFRLR
BFBFFBBRRL
FFBBFFBRRR
BFFBFBBLRL
FFBFBFBLLL
BBFFFBFRLL
FBFBBBFRRR
BFFBBFFLRR
BFBBFFBLRL
BFFFFFBLLL
BBFFFFFRLR
FBBFFBFRLL
FFBFBFFRRR
BFBBBBFLRR
BFFBBFFRLL
BFBBFFBLLL
BFFFFFBRRR
FBBFFFBLRL
FFFBBBFRLR
FFBBBFBRRL
BFFFBBBRRL
FFBFBFBRRR
FBBBBBFRRR
BBFBFFFRLL
FBFFFBBLRR
FBFBFFBRRR
BFBFBFBRLR
FBBBFFFRRL
BFBFFFBRLL
FB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R
FFBBFFFLLL
BFFBBBFRLL
FFBBBBFRLL
FFFFBFFLRR
FFBBBBBLRL
FBBBBBBLRR
FBBFFFBLLR
BBFFFBBRLL
BFFBBFFLRL
FFFBFBFRRR
FBFBFBBLLL
FBBBBBFRLL
FBBBBBBRRL
FBFBBBBRRL
FBFFBFFRRL
BFFFBBFLLR
BFFBFFFLRR
BFFBBFBLRR
FFFFBFBRLL
BFFBFFFLRL
FFBFFFBLRL
FBBFFFBLRR
BFBBBFFLRL
FBFFBBFLRL
BFFFBBBRLR
BFFBFBBRRR
BFFFFFBLRL
BBFBFFFLRL
BFBFBBFRRL
BBFFBFFLRR
FBFBFBBLRL
BFBFBBFRLR
FFFBBBBRRR
FBFFFFBLLR
FBFBBFFRLL
BFBFFBFRRR
FFFBFFBLLR
FBFBFBFLRL
FBBFBBBRLR
FFFBFBBLLR
FFBBFFFRLL
BFBFFBBRLR
BBFFFFBLLL
FFBBBFFRRR
BFFBFFFRLR
FFBFFBBLRL
FBBBFFBRRR
BFBFBBFRLL
BFBBBBFRRL
BFBBFFBRLL
BBFFFBBLRL
FFBBBBFRRR
BBFFFBFRRR
BFBFFFFLRR
FFFBFBBLRR
BFFBBFBRRL
FBBFBBBRRR
FBFBFFFLRL
BFBBFBFRLR
FFFBFFFLRL
FFBBBFBRRR
FBBFFBBRRR
BBFFFBBLLR
FFFBFFBLRL
FFBFBBBRRL
FFBBBFFLLR
FBFFBBFRLR
FBFFFBFLRL
FFBBFBBRRL
FFFBBFFRRL
FBBFBBFRLR
FBFBBFFRRR
FFFFBFFRRR
BFFFFFBLRR
BBFFFFBRRL
FBBBFFBLRR
BFFBFBFRLL
FFBFFFBRRL
FFBFBFBLLR

``````use crate::common::AdventOfCodeDay;

use std::u32;

#[derive(Debug)]
struct BoardingPass {
row: u32,
column: u32,
}

#[derive(Debug)]
pub struct Day05 {
input: Vec<BoardingPass>,
}

impl BoardingPass {
fn seat_id(&self) -> u32 { self.row * 8 + self.column }
}

fn parse_line(val: &str) -> BoardingPass {

let sval = val.to_owned()
.replace("F", "0")
.replace("B", "1")
.replace("R", "1")
.replace("L", "0");

BoardingPass {
row:    u32::from_str_radix(&sval[0..7],  2).unwrap(),
column: u32::from_str_radix(&sval[7..10], 2).unwrap(),
}
}

impl Day05 {
pub fn new() -> Self {
let input_bytes = include_bytes!("../res/05_input.txt");
let input_str = String::from_utf8_lossy(input_bytes);

let data = input_str
.lines()
.map(parse_line)
.collect::<Vec<BoardingPass>>();

Self {
input: data
}
}
}

impl AdventOfCodeDay for Day05 {

fn task_1(&self) -> String {
verboseln!("{:?}", self.input);
return self.input.iter().map(|p| p.seat_id()).max().unwrap().to_string()
}

fn task_2(&self) -> String  {
let min = self.input.iter().map(|p| p.seat_id() as u64).min().unwrap();
let sum = self.input.iter().map(|p| p.seat_id() as u64 - min).sum::<u64>(); // sum of all pass numbers

let allsum = (self.input.len() * (self.input.len() + 1) / 2) as u64; // sum if all pass numbers are there

let missing = (allsum - sum) + min; // diff = the _one_ missing number

return missing.to_string()
}
}``````
Result Part 1: 842
Result Part 2: 617

made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary* javascript