/[symmetry-circle]/symmetry.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /symmetry.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by dpavlin, Mon Aug 27 12:09:15 2007 UTC revision 10 by dpavlin, Fri Aug 31 14:23:21 2007 UTC
# Line 232  foreach my $start ( @shapes_start ) { Line 232  foreach my $start ( @shapes_start ) {
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  }  }

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26