6 static void do_tile(tile_t **tiles, int row, int col)
8 tile_t *t = &tiles[row][col];
9 tile_t *l = &tiles[row][col-1];
10 tile_t *r = &tiles[row][col+1];
11 tile_t *u = &tiles[row-1][col];
12 //tile_t *d = &tiles[row+1][col];
14 /* Fill in what we know */
15 switch (tiles[row][col].c) {
16 case '-': t->top = LEFT | RIGHT; break;
17 case '|': t->top = UP | DOWN; break;
18 case '\'': t->top = UP; break;
19 case '.': t->top = DOWN; break;
23 if (t->c == '|' && (l->top | l->bot) & RIGHT)
24 t->bot = LEFT | RIGHT;
25 if (t->c == '-' && (u->top | u->bot) & DOWN)
28 /* Adds sides for ''s and .'s */
29 if (t->c == '.' || t->c == '\'') {
30 if ((l->top | l->bot) & RIGHT)
38 static void print_ptrn(int ptrn)
40 printf("%c", ptrn & LEFT ? '<' : '-');
41 printf("%c", ptrn & RIGHT ? '>' : '-');
42 printf("%c", ptrn & UP ? '^' : '-');
43 printf("%c", ptrn & DOWN ? 'v' : '-');
50 for (int i = 0; i < 64; i++)
51 tiles[i] = calloc(512, sizeof(tile_t));
56 while ((c = getchar()) != EOF) {
57 if (row > 63 || col > 511)
63 tiles[row][col].c = c;
69 for (row = 1; row < 63; row++)
70 for (col = 1; col < 511; col++)
71 do_tile(tiles, row, col);
74 //for (row = 1; row < 63; row++) {
75 // for (col = 1; col < 511; col++) {
76 // print_ptrn(tiles[row][col].top);
77 // print_ptrn(tiles[row][col].bot);