diff options
Diffstat (limited to '12.c')
-rw-r--r-- | 12.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -75,7 +75,7 @@ tryvisit(unsigned char * range, int cols, int rows, struct pos const * from, int // Check height src = range[from->x + from->y * cols]; - if (height(dst) > height(src) + 1) + if (height(dst) < height(src) - 1) return 0; // OK. We can visit, so mark the new position as visited. @@ -126,9 +126,9 @@ main() } rows = rangelen / cols; - // Find start, and mark it as visited - if ((p = memchr(range, 'S', rangelen)) == NULL) { - fprintf(stderr, "No start position!\n"); + // Find end, and mark it as visited + if ((p = memchr(range, 'E', rangelen)) == NULL) { + fprintf(stderr, "No end position!\n"); free(range); return -1; } @@ -141,8 +141,8 @@ main() struct pos * loc; for (loc = front; loc != NULL; loc = loc->next) { - if ((range[loc->x + loc->y * cols] & 0x7F) == 'E') - // We found the end point! + if ((range[loc->x + loc->y * cols] & 0x7F) == 'S') + // We found the start point! break; if (tryvisit(range, cols, rows, loc, -1, 0)) @@ -167,9 +167,9 @@ main() } if (front) - printf("Found end at %d,%d in %d steps\n", front->x, front->y, steps); + printf("Found start at %d,%d in %d steps\n", front->x, front->y, steps); else - printf("No end found after %d steps\n", steps); + printf("No start found after %d steps\n", steps); pos_free(front); free(range); |