Advent of Code

Artifact [3f85574365]
Login

Artifact [3f85574365]

Artifact 3f85574365f639a2bb904ffe10468e3244b7f61cfef40c28f9b83d6c74492c0e:


#ifndef AOCUTILS_H_INCLUDED
#define AOCUTILS_H_INCLUDED

#include <stdbool.h>

struct TextGrid {
    unsigned rows, cols;
    char *data; // may have '\n' at end of rows
};

bool TGvalid(struct TextGrid *tg, unsigned row, unsigned col);
char *TGcharptr(struct TextGrid *tg, unsigned row, unsigned col);

size_t linearize2d(unsigned width, unsigned row, unsigned col); // TODO
size_t text2array(unsigned **dst, const char *txt);
size_t slurp(char **dst, const char *filename);
unsigned distance(unsigned a, unsigned b);
unsigned max3u(unsigned a, unsigned b, unsigned c);
unsigned min3u(unsigned a, unsigned b, unsigned c);

#endif