10 for my $step (split /,/, $desc) {
11 my ($dir, $dist) = $step =~ /([A-Z])(\d+)/;
13 ($dx, $dy) = (1, 0) if $dir eq 'R';
14 ($dx, $dy) = (0, 1) if $dir eq 'D';
15 ($dx, $dy) = (0, -1) if $dir eq 'U';
16 ($dx, $dy) = (-1, 0) if $dir eq 'L';
17 $rv{$x += $dx, $y += $dy} = 1 while $dist--;
18 say "$step -> $x, $y";
23 my $p1 = walk(scalar <>);
24 my $p2 = walk(scalar <>);
27 for my $pos (keys %$p1) {
29 my ($x, $y) = split /,/, $pos;
30 my $d = abs($x)+abs($y);
31 $dist = $d if !$dist || $dist > $d;