aocc22

Advent of Code 2022
git clone git://www.tkruger.se/aocc22.git
Log | Files | Refs | README

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 }