Advent of code 2020/5
Ajax Direct

Answer

Part 1 :
Part 2 :
function comp($l) {
    return match ($l) {
        "F", "L" => -1,
        "B", "R" => 1,
        default => 0
    };
}

$ids = $input->lines->map(function ($l) {
    [$row, $seat] = $l->chars()->chunk(7);
    $x = binary_search(0, 127, fn () => comp($row->shift()), false);
    $y = binary_search(0, 7, fn () => comp($seat->shift()), false);
    return round($x) * 8 + round($y);
});

// ==================================================
// > PART 1
// ==================================================
$solution_1 = $ids->max();

// ==================================================
// > PART 2
// ==================================================
$solution_2 = set(range($ids->min(), $ids->max()))->remove($ids)->first();