Advent of code 2018/10
Ajax Direct

Answer

Part 1 :
Part 2 :
$points = $input->lines->map(fn ($l) => $l->numbers());

function get_message($points, $time = 0) {
    $grid = new Grid();
    foreach ($points as $p) {
        $grid->set([$p[0] + $p[2] * $time, $p[1] + $p[3] * $time], "#");
    }
    return $grid;
}


// Start at an heuristic time
$time = round(abs($points[0][0] / $points[0][2]));
$width = INF;

// Find the first time where the message is the smallest
while (true) {
    $grid = get_message($points, $time);
    if ($grid->width() > $width) break;
    $width = $grid->width();
    $time++;
}

$solution_1 = (string) get_message($points, $time - 1);
$solution_2 = $time - 1;