// ==================================================
// > PART 1
// ==================================================
$af = array_sum(range(1, 500)); // Acceleration factor
$solution_1 = $input->lines->map(function ($line) use ($af) {
[$pos, $speed, $accel] = $line->numbers()->map("abs")->chunk(3)->callEach()->sum();
return $pos + (500 * $speed) + $af * $accel;
})->sort()->keys()->first();
// ==================================================
// > PART 2 - I really have to simulate particles, huh?
// ==================================================
$prtcls = $input->lines->map(fn ($line) => $line->numbers()->chunk(3));
for ($i = 0; $i < 500; $i++) {
foreach ($prtcls as $j=>$p) {
$p[1] = [$p[1][0] + $p[2][0], $p[1][1] + $p[2][1], $p[1][2] + $p[2][2]];
$p[0] = [$p[0][0] + $p[1][0], $p[0][1] + $p[1][1], $p[0][2] + $p[1][2]];
$prtcls[$j] = $p;
}
$dups = (array) $prtcls->map(fn ($p) => implode(",", $p[0]))->duplicates();
if ($dups) $prtcls = $prtcls->filter(fn ($p) => !in_array(implode(",", $p[0]), $dups));
}
$solution_2 = $prtcls->count();