21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
struct TextGrid tg;
tg.data = data;
tg.cols = strchr(data, '\n') - data + 1;
tg.rows = tg.cols - 1; // rows includes the '\n'
#if 0
unsigned anti[256][2]; // locations of antinodes
unsigned nanti = 0;
unsigned size = 1 + strchr(data, '\n') - data;
for (unsigned row = 0; row < size-1; row++) {
for (unsigned col = 0; col < size-1; col++) {
char *p = data + linearize2d(size, row, col);
if (*p != '.') {
char *q = strchr(p + 1, *p);
while (q) {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
struct TextGrid tg;
tg.data = data;
tg.cols = strchr(data, '\n') - data + 1;
tg.rows = tg.cols - 1; // rows includes the '\n'
#if 0
unsigned anti[256][2]; // locations of antinodes
unsigned nanti = 0;
#endif
char *p = data;
while (*p) {
while ((*p == '.') || (*p == '\n')) p++;
if (*p) {
// p points to an antenna
char *q = strchr(p+1, *p);
while (q) {
// q points to an antenna of the same type as p
printf("p is at (C:%u, R:%u); q is at (C:%u, R:%u)\n",
TGcol(&tg, p), TGrow(&tg, p),
TGcol(&tg, q), TGrow(&tg, q));
q = strchr(q+1, *p); // next antenna of this type
}
p += 1;
}
}
#if 0
unsigned size = 1 + strchr(data, '\n') - data;
for (unsigned row = 0; row < size-1; row++) {
for (unsigned col = 0; col < size-1; col++) {
char *p = data + linearize2d(size, row, col);
if (*p != '.') {
char *q = strchr(p + 1, *p);
while (q) {
|