commit d75236faa9c5d3388dffb6635520a379aa657dc0
parent bdb93446e25e46a3cf9356d1df84973dfeab863a
Author: Louis Burda <quent.burda@gmail.com>
Date: Fri, 17 Mar 2023 16:50:02 +0100
Fixup day 5
Diffstat:
3 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/05/Makefile b/05/Makefile
@@ -1,13 +0,0 @@
-CFLAGS = -g -I ../../libs/include -L ../../libs/build
-LDLIBS = -licc -laoc
-
-all: lib main
-
-clean:
- rm main
-
-lib:
- make -C ../../libs
-
-main: main.c ../../libs/build/*
- $(CC) -o $@ $< $(CFLAGS) $(LDLIBS)
diff --git a/05/info.mk b/05/info.mk
@@ -0,0 +1,3 @@
+05_SRC = 05/main.c common/main.c common/icc.c common/aoc.c common/util.c
+05_SRC += lib/libdvec/build/libdvec.a
+05_HDR = common/aoc.h common/icc.h common/util.h
diff --git a/05/main.c b/05/main.c
@@ -1,5 +1,6 @@
#include "aoc.h"
#include "icc.h"
+#include "util.h"
#include <stdlib.h>
#include <stdio.h>
@@ -10,26 +11,26 @@ part1(void)
struct icc icc;
int code;
- ASSERT(icc_init(&icc) == OK);
- ASSERT(icc_parse_inst(&icc, aoc.input, aoc.input_size) == OK);
+ icc_init(&icc);
+ icc_parse_inst(&icc, aoc.input, aoc.input_size);
- while (icc.status != ICC_HALT) {
+ while (icc.state != ICC_HALT) {
icc_step_inst(&icc);
- switch (icc.status) {
+ switch (icc.state) {
case ICC_INPUT:
icc.in = 1;
break;
case ICC_OUTPUT:
- debug("OUTPUT: %i\n", icc.out);
+ aoc_debug("OUTPUT: %i\n", icc.out);
code = icc.out;
break;
}
}
- aoc.answer = CHKP(aprintf("%i", code));
+ aoc.answer = aprintf("%i", code);
aoc.solution = "15314507";
- icc_free(&icc);
+ icc_deinit(&icc);
}
void
@@ -38,23 +39,24 @@ part2(void)
struct icc icc;
int code;
- ASSERT(icc_init(&icc) == OK);
- ASSERT(icc_parse_inst(&icc, aoc.input, aoc.input_size) == OK);
+ icc_init(&icc);
+ icc_parse_inst(&icc, aoc.input, aoc.input_size);
- while (icc.status != ICC_HALT) {
+ while (icc.state != ICC_HALT) {
icc_step_inst(&icc);
- switch (icc.status) {
+ switch (icc.state) {
case ICC_INPUT:
icc.in = 5;
break;
case ICC_OUTPUT:
- debug("OUTPUT: %i\n", icc.out);
+ aoc_debug("OUTPUT: %i\n", icc.out);
code = icc.out;
break;
}
}
- aoc.answer = CHKP(aprintf("%i", code));
+ aoc.answer = aprintf("%i", code);
+ aoc.solution = "652726";
- icc_free(&icc);
+ icc_deinit(&icc);
}