6 use Digest::MD5 qw(md5_hex);
9 my @paths = [ 0, 0, '' ];
13 my ($x, $y, $path) = @$p;
15 if ($x == 3 && $y == 3) {
20 my $h = md5_hex($in.$path);
21 if ($y > 0 && substr($h, 0, 1) =~ /[b-f]/) {
22 push @paths, [ $x, $y-1, $path.'U' ];
24 if ($y < 3 && substr($h, 1, 1) =~ /[b-f]/) {
25 push @paths, [ $x, $y+1, $path.'D' ];
27 if ($x > 0 && substr($h, 2, 1) =~ /[b-f]/) {
28 push @paths, [ $x-1, $y, $path.'L' ];
30 if ($x < 3 && substr($h, 3, 1) =~ /[b-f]/) {
31 push @paths, [ $x+1, $y, $path.'R' ];