// putchar('\n');
}
+static void print_matches(conf c)
+{
+ printf("@@");
+ for (int i=0; i<SIZE; i++)
+ for (int j=1-i%2; j<SIZE; j+=2)
+ if (c[i][j])
+ {
+ if (i%2)
+ printf(" (%d,%d)-(%d,%d)", i/2, j/2, i/2+1, j/2);
+ else
+ printf(" (%d,%d)-(%d,%d)", i/2, j/2, i/2, j/2+1);
+ }
+ putchar('\n');
+}
+
static void norm(conf from, conf to)
{
int ii=SIZE, jj=SIZE;
to[i][j] = 0;
}
}
- printf("Degree: %d in, %d out, from=%d\n\n", s->indegree, s->outdegree, s->from);
+ printf("Degree: %d in, %d out, from=%d\n", s->indegree, s->outdegree, s->from);
+ print_matches(s->c);
+ putchar('\n');
}
}
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Cairo;
+
+my $u = 72/4;
+my $s = Cairo::PdfSurface->create('digit.pdf', 7*$u, 7*$u);
+my $c = Cairo::Context->create($s);
+my $n = 0;
+
+$c->set_line_width(2);
+$c->set_line_cap('round');
+$c->set_source_rgb(0, 0, 0);
+
+while (<>) {
+ s/^@@ // or next;
+ chomp;
+ my @r = split /\s+/;
+ @r == 5 or next;
+
+ for my $r (@r) {
+ my ($x1,$y1,$x2,$y2) = $r =~ /^\((\d+),(\d+)\)-\((\d+),(\d+)\)$/ or die;
+ $c->move_to((.9*$x1+.1*$x2)*$u, (.9*$y1+.1*$y2)*$u);
+ $c->line_to((.9*$x2+.1*$x1)*$u, (.9*$y2+.1*$y1)*$u);
+ $c->stroke;
+ }
+
+ $c->show_page;
+ $n++;
+}
+
+print "Output $n pages.\n";