From 16fcc29931b071d89aa8e137e85671673501c837 Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 12 Dec 2020 10:06:26 +0000 Subject: [PATCH] day12: start --- day12/Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ day12/day12.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 day12/Makefile create mode 100644 day12/day12.c diff --git a/day12/Makefile b/day12/Makefile new file mode 100644 index 0000000..dcb9b4c --- /dev/null +++ b/day12/Makefile @@ -0,0 +1,44 @@ + +OPT_FLAGS?= -march=native -flto \ + -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \ + -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \ + -fno-stack-check -fno-strict-aliasing + +CFLAGS+= -Wall -pedantic --std=gnu11 -Wextra -Wstrict-aliasing +CFLAGS+= $(OPT_FLAGS) +CFLAGS+= -O3 -pipe +LDFLAGS?= -O3 -flto + +INCLUDE?=../common/include +CFLAGS+= -I$(INCLUDE) + +STRIP=strip + +.PHONY: all +all: part1 part2 + +.PHONY: test +test: part1-test part2-test + +inpu%.h: inpu% + @rm -f $@ + while read line; do \ + echo "\"$$line\"," >> $@; \ + done < $< + +part1: day12.c | input.h + $(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) + $(STRIP) $@ + +part1-test: day12.c | input-test.h + $(CC) $< -DTEST $(CFLAGS) -o $@ $(LDFLAGS) + +part2: day12.c | input.h + $(CC) $< -DPART2 $(CFLAGS) -o $@ $(LDFLAGS) + $(STRIP) $@ + +part2-test: day12.c | input-test.h + $(CC) $< -DTEST -DPART2 $(CFLAGS) -o $@ $(LDFLAGS) +clean: + rm -f input{,-test}.h + rm -f part{1,2}{,-test} diff --git a/day12/day12.c b/day12/day12.c new file mode 100644 index 0000000..98b41e0 --- /dev/null +++ b/day12/day12.c @@ -0,0 +1,39 @@ +#include + +typedef uint64_t u64; + +const char* const input[] = { +#include "input.h" +}; +#define input_sz (sizeof(input)/sizeof(char*)) + +typedef struct { + u64 x, y; +} point_t; + +typedef struct { + enum direction { + DIR_NORTH, + DIR_SOUTH, + DIR_EAST, + DIR_WEST, + + DIR_LEFT, + DIR_RIGHT, + + DIR_FORWARD, + } dir; + u64 num; +} command_t; + +typedef struct ship { + point_t pos; + enum direction facing; +} svec_t; + + +int main() +{ + return 0; +} +