Advent of code 2021/2
Ajax Direct

Answer 10ms

Part 1 : 2120749 Part 2 : 2138382217
$directions = $input->lines->map(fn ($line) => explode(" ", $line))->map(fn ($line) => [direction($line[0]), (int) $line[1]]);

// ==================================================
// > PART 1
// ==================================================
$solution_1 = set(xy()->directions($directions)->xy)->multiply();

// ==================================================
// > PART 2
// ==================================================
$x = $y = $aim = 0;

foreach ($input->lines as $move) {
    [$direction, $count] = explode(" ", $move);

    switch ($direction) {
        case "down":
            $aim += $count; break;
        case "up":
            $aim -= $count; break;
        case "forward":
            $x += $count;
            $y += $aim * $count;
            break;
    }
}

$solution_2 = $x * $y;