function solve($input, $r) {
for ($i = 0; $i < $input->lines->count(); $i++) {
$c = explode(" ", $input->lines[$i]->string);
switch ($c[0]) {
case "cpy":
$r[$c[2]] = $r[$c[1]] ?? $c[1]; break;
case "inc":
$r[$c[1]]++; break;
case "dec":
$r[$c[1]]--; break;
case "jnz":
if ($r[$c[1]] ?? $c[1]) $i += $c[2] - 1; break;
}
}
return $r["a"];
}
// ==================================================
// > SOLUTIONS
// ==================================================
$r = array_fill_keys(["a", "b", "c", "d"], 0);
$solution_1 = solve($input, $r);
$r["c"] = 1;
$solution_2 = solve($input, $r);