aocc22

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

common.h (645B)


      1 #ifndef COMMON_H_
      2 #define COMMON_H_
      3 
      4 #include <assert.h>
      5 #include <reading.h>
      6 #include <stdint.h>
      7 #include <stdio.h>
      8 
      9 #define FRE 1
     10 #define STP 2
     11 #define NON 0
     12 
     13 #define NDIR 4
     14 
     15 enum direction { NORTH, EAST, SOUTH, WEST };
     16 
     17 typedef struct {
     18   size_t h;
     19   size_t w;
     20   uint8_t *data;
     21 } board;
     22 
     23 typedef struct {
     24   size_t x;
     25   size_t y;
     26 
     27   enum direction dir;
     28 } pos;
     29 
     30 typedef struct {
     31   uint64_t n;
     32   char turn;
     33 } move;
     34 
     35 size_t parse(board *b, pos *p, move **m, const char **lines,
     36              const size_t nlines);
     37 int64_t score_pos(pos *p);
     38 void make_move(pos *p, const board *b, move m);
     39 void make_move_b(pos *p, const board *b, move m);
     40 
     41 #endif