summary refs log tree commit diff homepage
path: root/2023
diff options
context:
space:
mode:
Diffstat (limited to '')
-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);
+}