preg_match("/Begin in state (\w)/", $input->string, $state);
$state = $state[1];
preg_match("/checksum after (\d+) steps/", $input->string, $steps);
$steps = (int) $steps[1];
$states = $input->lines->filter()->slice(2)->chunk(9)->mapAssoc(fn ($i, $state) => [
$state[0][strlen($state[0]) - 2] =>
$state->slice(1)->chunk(4)->mapAssoc(fn ($i, $chunk) => [
$chunk[0][strlen($chunk[0]) - 2] => [
$chunk[1][strlen($chunk[1]) - 2],
substr($chunk[2], -6, -1) == "right" ? 1 : -1,
$chunk[3][strlen($chunk[3]) - 2]
]
])
]);
$tape = [];
$pos = 0;
for ($i = 0; $i < $steps; $i++) {
$value = $tape[$pos] ?? 0;
$tape[$pos] = $states[$state][$value][0];
$pos += $states[$state][$value][1];
$state = $states[$state][$value][2];
}
$solution_1 = array_sum($tape);
$solution_2 = "⭐";