Advent of code 2017/2
Ajax Direct

Answer

Part 1 :
Part 2 :
// ==================================================
// > PART 1
// ==================================================
$solution_1 = $input->lines->map(fn ($line) =>
    $line->numbers()->max() - $line->numbers()->min()
)->sum();

// ==================================================
// > PART 2
// ==================================================
$solution_2 = $input->lines->map(function ($line) {
    $nums = $line->numbers();
    foreach ($nums->combinations(2, 2) as $c) {
        if ($c[0] % $c[1] === 0) return $c[0] / $c[1];
        if ($c[1] % $c[0] === 0) return $c[1] / $c[0];
    }
})->sum();