From 835da02e31dec8fc69481066120d4ae707eb65a9 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 6 Dec 2020 00:15:38 -0500 Subject: Solve day 6 part 1 --- 2020/day06.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 2020/day06.c (limited to '2020') diff --git a/2020/day06.c b/2020/day06.c new file mode 100644 index 0000000..07c40a3 --- /dev/null +++ b/2020/day06.c @@ -0,0 +1,21 @@ +#include +#include +int main (void) { + size_t cap = 0; + char *buf = NULL; + unsigned groups[512] = {0}; + for (int i = 0; 0 < getline(&buf, &cap, stdin);) { + if (buf[0] == '\n') { + i++; + continue; + } + for (char *ch = buf; *ch && *ch != '\n'; ++ch) { + groups[i] |= 1 << (*ch - 'a'); + } + } + int sum = 0; + for (int i = 0; i < 512; ++i) { + sum += __builtin_popcount(groups[i]); + } + printf("%d\n", sum); +} -- cgit 1.4.1 class='sub right'>
summary refs log tree commit diff
Commit message (Expand)Author
2021-01-12Use hilex for bin HTMLJune McEnroe
2021-01-12Don't output a pre in hilex by defaultJune McEnroe
2021-01-12Move hilex out of hilex directoryJune McEnroe
2021-01-12Consolidate hilex formatters into hilex.cJune McEnroe
2021-01-12Remove hacky tagging from hilexJune McEnroe
2021-01-12Add htagml -iJune McEnroe
2021-01-12Render tag index in HTMLJune McEnroe
2021-01-12Add htagml -xJune McEnroe
2021-01-12Prevent matching the same tag twiceJune McEnroe
2021-01-12Process htagml file line by lineJune McEnroe
2021-01-12Split fields by tab onlyJune McEnroe
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
2021-01-09Add c -t flag to print expression typeJune McEnroe
2021-01-05Update taglineJune McEnroe