Advent of code 2021/13
Ajax Direct

Answer 12ms

Part 1 : 689 Part 2 : ###  #    ###   ##    ##  ##  #    #  #
#  # #    #  # #  #    # #  # #    #  #
#  # #    ###  #       # #    #    #  #
###  #    #  # #       # # ## #    #  #
# #  #    #  # #  # #  # #  # #    #  #
#  # #### ###   ##   ##   ### ####  ## 
[$points, $folds] = $input->split("\n\n");
$points = (array) $points->lines->mapAssoc(fn ($v, $xy) => [(string) $xy => true]);

foreach ($folds->lines as $fold) {
    [$_, $dir, $fold] = $fold->match("/(x|y)=([0-9]+)/");

    $npoints = [];

    foreach ($points as $point=>$v) {
        [$x, $y] = explode(",", $point);

        if ($dir == "y" && $y > $fold) {
            $y = $fold - ($y - $fold);
        }

        if ($dir == "x" && $x > $fold) {
            $x = $fold - ($x - $fold);
        }

        $npoints["$x,$y"] = true;
    }

    $solution_1 = $solution_1 ?? count($npoints);
    $points = $npoints;
}

$grid = grid();
foreach ($points as $xy=>$v) {
    $grid->set(explode(",", $xy), "#");
}
$solution_2 = $grid->fillVoid()->rows()->callEach()->join("")->join("<br>");