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 selected='selected'>master dontfiles
summary refs log tree commit diff
Commit message (Collapse)Author
2021-01-12Add htagml -xJune McEnroe
2021-01-12Prevent matching the same tag twiceJune McEnroe
2021-01-12Process htagml file line by lineJune McEnroe
This simplifies some things, adds support for line number tag definitions, and should enable combining htagml with other preprocessors in the future.
2021-01-12Split fields by tab onlyJune McEnroe
Also don't fail hard on non-forward-search definitions.
2021-01-12List both Makefile and html.sh under README.7June McEnroe
2021-01-12Add htagml exampleJune McEnroe
2021-01-12Use mandoc and htagml for bin htmlJune McEnroe
2021-01-12Add htagmlJune McEnroe
2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe
2021-01-11Publish "Using vi"June McEnroe
2021-01-11Enable diff.colorMovedJune McEnroe
2021-01-10Set less search case-insensitiveJune McEnroe
2021-01-10Set EXINITJune McEnroe
neovim is laggy as hell in my OpenBSD VM, so I switched to vi so I could type without getting frustrated.
2021-01-09Add c -t flag to print expression typeJune McEnroe
Also add missing float case.
2021-01-05Update taglineJune McEnroe