6 use Digest::MD5 qw(md5_hex);
9 my @paths = [ 0, 0, '' ];
14 my ($x, $y, $path) = @$p;
16 if ($x == 3 && $y == 3) {
17 $max = length $path if !$max || $max < length $path;
21 my $h = md5_hex($in.$path);
22 if ($y > 0 && substr($h, 0, 1) =~ /[b-f]/) {
23 push @paths, [ $x, $y-1, $path.'U' ];
25 if ($y < 3 && substr($h, 1, 1) =~ /[b-f]/) {
26 push @paths, [ $x, $y+1, $path.'D' ];
28 if ($x > 0 && substr($h, 2, 1) =~ /[b-f]/) {
29 push @paths, [ $x-1, $y, $path.'L' ];
31 if ($x < 3 && substr($h, 3, 1) =~ /[b-f]/) {
32 push @paths, [ $x+1, $y, $path.'R' ];