$city = grid();
$me = xy();
$facing = "up";
foreach ($input->split(",")->map("trim") as $direction) {
$d = $direction[0];
$c = substr($direction, 1);
$facing = facing($facing, direction($d));
$me->direction($facing, $c);
}
// ==================================================
// > PART 1
// ==================================================
$solution_1 = $me->manhattan([0, 0]);
// ==================================================
// > PART 2
// ==================================================
$solution_2 = xy(json_decode(
$me->getFullHistory()->map("json_encode")->duplicates(2)->first())
)->manhattan([0, 0]);