Advent of code 2021/5
Ajax Direct

Answer

Part 1 :
Part 2 :
function solve($points, $diagonals = false) {
    $lines = [];

    foreach ($points as [$x1, $y1, $x2, $y2]) {
        if ($diagonals || ($x1 == $x2 || $y1 == $y2)) {
            $lines = array_merge($lines, GridPointer::getInbetween([$x1, $y1], [$x2, $y2]));
        }
    }

    return set($lines)->map(fn ($xy) => implode(";", $xy))->duplicates(2)->count();
}

// ==================================================
// > SOLUTIONS
// ==================================================
$points     = $input->numbers()->chunk(4);
$solution_1 = solve($points, false);
$solution_2 = solve($points, true);