-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxf.pl
More file actions
62 lines (54 loc) · 1.21 KB
/
Copy pathxf.pl
File metadata and controls
62 lines (54 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Take an eight character string representing the board layout
# e.g perl xf.pl 36271405
# and return all mirrors and rotations (12 total -- not necessarily distinct)
my $s = shift;
my @am, @a90, @a90m;
#my @a = split //,$s;
my @a = split //,$s;
#print map "$_ ", @a;
for (my $i = 0; $i < 8; $i++) {
$am[$i] = 7 - $a[$i];
$a90[$a[$i]] = 7 - $i;
#$a90[$a[7-$i]] = $i; # Identical to a90
$a90m[$a[$i]] = $i;
$a180[$i] = 7 - $a[7-$i];
$a180m[$i] = $a[7-$i];
$a270[7-$a[$i]] = $i;
$a270m[7-$a[$i]] = 7 - $i;
#$a270m[7-$a[7-$i]] = $i;
$t[7-$a[7-$i]] = $i;
}
sub p {
my $name = shift;
my @arr = @_;
printf "%-5.5s %8s\n",$name,join '',@_;
}
sub t90 {
my @s = split //,shift;
my @s90 = ();
while (my ($i, $v) = each @s) { @s90[$v] = 7-$i; }
return join '',@s90
}
sub mirror {
my $s = shift;
my $sm;
($sm = $s) =~ tr/01234567/76543210/;
return $sm;
}
p("a",@a);
p("am",@am);
p("a90",@a90);
p("a90m",@a90m);
p("a180",@a180);
p("a180m",@a180m);
p("a270",@a270);
p("a270m",@a270m);
=disabled
p("test",@t);
$sm = mirror($s);
printf "%-5.5s %s\n","a",$s;
printf "%-5.5s %s\n","am",$sm;
printf "%-5.5s %s\n","a90",t90($s);
printf "%-5.5s %s\n","a180",t90(t90($s));
printf "%-5.5s %s\n","a270",t90(t90(t90($s)));
=cut