uppga.c (458B)
1 #include "common.h" 2 3 int main(int argc, char **argv) { 4 char **lines; 5 size_t nlines = readlines(&lines, "input"); 6 7 size_t h, w; 8 size_t pos[4]; 9 uint8_t **grid = parse(&h, &w, pos, lines, nlines); 10 11 uint64_t *stepsto = malloc(h * w * sizeof(*stepsto)); 12 memset(stepsto, 0xff, h * w * sizeof(*stepsto)); 13 14 stepsto[pos[2] * w + pos[3]] = 0; 15 calculate_steps(stepsto, pos[2], pos[3], h, w, grid); 16 17 printf("%llu\n", stepsto[pos[0] * w + pos[1]]); 18 }