aocc22

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

uppgb.c (698B)


      1 #include "common.h"
      2 
      3 int main(int argc, char **argv) {
      4   char **lines;
      5   size_t nlines = readlines(&lines, "input");
      6   printf("#lines: %lu\n", nlines);
      7 
      8   monki *m = parse(lines, nlines);
      9 
     10   size_t l_root = left_tree_root(m);
     11   size_t r_root = right_tree_root(m);
     12   printf("l_root = %zu, r_root = %zu\n", l_root, r_root);
     13 
     14   size_t h_root = l_root;
     15   size_t n_root = r_root;
     16   if (humn_subtree(l_root, m)) {
     17     printf("> humn in left\n");
     18   } else {
     19     printf("> humn in right\n");
     20     h_root = r_root;
     21     n_root = l_root;
     22   }
     23 
     24   int64_t match = mcompute(n_root, m);
     25   printf("> want to match %lld\n", match);
     26 
     27   int64_t revd = reverse(h_root, m, match);
     28   printf("%lld\n", revd);
     29 
     30   free(m);
     31 }