// ==================================================
// > PART 1
// ==================================================
$found = $input->matchAll("/mul\((\d{1,3}),(\d{1,3})\)/");
$solution_1 = set($found[1])->map((fn ($n, $i) => $n * $found[2][$i]), true)->sum();
// ==================================================
// > PART 2
// ==================================================
$found = $input->matchAll("/mul\((\d{1,3}),(\d{1,3})\)|do(?:n't)?\(\)/");
$do = true;
$solution_2 = 0;
foreach ($found[0] as $i=>$inst) {
if ($inst == "do()") {
$do = true;
} elseif ($inst == "don't()") {
$do = false;
} elseif ($do) {
$solution_2 += $found[1][$i] * $found[2][$i];
}
}