232 |
} |
} |
233 |
} |
} |
234 |
|
|
235 |
|
sub is_symmetric { |
236 |
|
my $path = shift || die "no path?"; |
237 |
|
|
238 |
|
my $h = length($path)/2; |
239 |
|
return 0 if int($h) != $h; |
240 |
|
my ($l,$r) = ( substr($path,0,$h), substr($path,$h) ); |
241 |
|
$r =~ tr/lrud/rldu/; |
242 |
|
# warn "$l -- $r\n"; |
243 |
|
return 0 unless $l eq $r; |
244 |
|
return 1; |
245 |
|
} |
246 |
|
|
247 |
print ">>> RESULTS:\n"; |
print ">>> RESULTS:\n"; |
248 |
foreach my $r ( @shapes_found ) { |
foreach my $r ( @shapes_found ) { |
249 |
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", |
250 |
|
$r->{x}, $r->{y}, $r->{len}, $r->{directions}, is_symmetric($r->{directions}) ? 'symetric' : ''; |
251 |
} |
} |