From 4d8a7d4dabac4088c3308e1dd6febfb072c20554 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 8 Dec 2018 21:43:35 -0500 Subject: Solve day 8 part 1 --- 2018/day08.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2018/day08.c diff --git a/2018/day08.c b/2018/day08.c new file mode 100644 index 0000000..a240786 --- /dev/null +++ b/2018/day08.c @@ -0,0 +1,28 @@ +#include +#include + +typedef unsigned uint; + +static uint sum; + +static void meta(void) { + uint meta; + scanf("%u", &meta); + sum += meta; +} + +static void node(void) { + uint nchild, nmeta; + scanf("%u %u", &nchild, &nmeta); + for (uint i = 0; i < nchild; ++i) { + node(); + } + for (uint i = 0; i < nmeta; ++i) { + meta(); + } +} + +int main() { + node(); + printf("%u\n", sum); +} -- cgit 1.4.1