--- symmetry.pl 2007/08/27 12:09:15 9 +++ symmetry.pl 2007/08/31 14:23:21 10 @@ -232,7 +232,20 @@ } } +sub is_symmetric { + my $path = shift || die "no path?"; + + my $h = length($path)/2; + return 0 if int($h) != $h; + my ($l,$r) = ( substr($path,0,$h), substr($path,$h) ); + $r =~ tr/lrud/rldu/; +# warn "$l -- $r\n"; + return 0 unless $l eq $r; + return 1; +} + print ">>> RESULTS:\n"; foreach my $r ( @shapes_found ) { - printf "%2d,%-2d len: %-4d directions: %s\n", $r->{x}, $r->{y}, $r->{len}, $r->{directions}; + printf "%2d,%-2d len: %-4d directions: %s %s\n", + $r->{x}, $r->{y}, $r->{len}, $r->{directions}, is_symmetric($r->{directions}) ? 'symetric' : ''; }