summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-12-09 15:28:47 -0500
committerJune McEnroe <june@causal.agency>2023-12-09 15:28:47 -0500
commit4997ef07a6da8b2950bbef60a207eb68ac598f00 (patch)
tree1694b35582ab2af87f7e61ad121b8ab5852f23a0
parentSolve day 1 part 2 (diff)
downloadaoc-4997ef07a6da8b2950bbef60a207eb68ac598f00.tar.gz
aoc-4997ef07a6da8b2950bbef60a207eb68ac598f00.zip
Solve day 2 part 1
-rw-r--r--2023/day02.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/2023/day02.c b/2023/day02.c
new file mode 100644
index 0000000..d24fb17
--- /dev/null
+++ b/2023/day02.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main(void) {
+	int game;
+	int sum = 0;
+	while (1 == scanf("Game %d: ", &game)) {
+		int n;
+		char c[6];
+		while (scanf("%d %5[a-z]%*c", &n, c) > 0) {
+			if (c[0] == 'r' && n > 12) game = 0;
+			if (c[0] == 'g' && n > 13) game = 0;
+			if (c[0] == 'b' && n > 14) game = 0;
+		}
+		sum += game;
+	}
+	printf("%d\n", sum);
+}
/td> Newer versions of libedit have sane tab-complete now without FreeBSD's hacks, and in fact the hack is gone in FreeBSD-CURRENT. I'm still a little confused why binding this weird function is necessary at all, but at least it exists everywhere, I guess. 2020-06-08Prefix mandoc with exec in about-filterJune McEnroe 2020-06-07Remove mktemp options from mkbuiltins, mktokensJune McEnroe Why even? 2020-06-07Cast z_stream fields to size_tJune McEnroe In the version of zlib in OpenBSD, these fields are of type off_t, which is signed (why?), rather than uLong. 2020-06-07Call static_assert by _Static_assertJune McEnroe OpenBSD doesn't #define static_assert in assert.h and _Static_assert is its real name I guess so why not? 2020-06-07Add OpenBSD to install.shJune McEnroe Straightforward. 2020-06-03Add The Song of AchillesJune McEnroe 2020-06-01Allow redirecting input in everJune McEnroe 2020-05-31Add %c conversion to c scriptJune McEnroe 2020-05-31Add c script to READMEJune McEnroe 2020-05-31Add c scriptJune McEnroe 2020-05-31Update mdoc source URLsJune McEnroe 2020-05-26Remove unfinished PSF fontsJune McEnroe