aocc22

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

uppga.c (360B)


      1 #include "common.h"
      2 
      3 int main(int argc, char **argv) {
      4   char **lines;
      5   size_t nlines = readlines(&lines, "input");
      6 
      7   assert(nlines == 1);
      8 
      9   char *s = lines[0];
     10   size_t len = strlen(s);
     11 
     12   size_t i, step = 0;
     13   for (i = 0; i < len; i += step, s += step) {
     14     if ((step = pairwise_diff(s, 4)) == 0) {
     15       printf("%zu\n", i + 4);
     16       break;
     17     }
     18   }
     19 }